[rt-users] Using custom fields for URLs

Niels Bakker niels=rt at bakker.net
Wed Oct 20 09:52:59 EDT 2004


Hi Tim,

* tim at ccc.de (Tim Pritlove) [Wed 20 Oct 2004, 14:36 CEST]:
> Is there any way to make RT "know" that these are in fact URLs so that 
> it can display the links as links and not as text?

Although it won't solve the non-wrapping of overly long URLs, try the
attached patch to make links clickable.  Naming the anchor shouldn't be
a major overhaul.

Good reasons exist for this functionality to have been removed from RT2
to RT3.  Please be aware that this can be a security issue (XSS).

The regexp is based on http://www.foad.org/~abigail/Perl/url2.html

Cheers,


	-- Niels.

-- 
-------------- next part --------------
--- html/Ticket/Elements/ShowMessageStanza	2004-02-13 19:21:02.000000000 +0100
+++ html/local/Ticket/Elements/ShowMessageStanza	2004-10-20 15:45:51.000000000 +0200
@@ -37,6 +37,9 @@
         $m->comp('/Elements/Callback', content => \$content, %ARGS);
                 $content =~ s/\n/<br>/gi;
 
+        # Make URLs in plaintext clickable.  This is dangerous!
+        $content =~ s@(http://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:\@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:\@&=])*))*)(?:\?(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:\@&=])*))?)?)|(?:ftp://(?:(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;?&=])*)(?::(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;?&=])*))?\@)?(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?))(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[?:\@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[?:\@&=])*))*)(?:;type=[AIDaid])?)?)|(?:mailto:(?:(?:[a-zA-Z\d$\-_.+!*'(),;/?:\@&=]|(?:%[a-fA-F\d]{2}))+))@<a href=\"$1\" target=\"_blank\">$1</a>@g;
+
 </%perl>
 <%$content |n%><br>
 %       }


More information about the rt-users mailing list