about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-02-09 22:33:50 +0000
committerEric Wong <e@80x24.org>2015-02-09 22:34:46 +0000
commite90a7953217879258cee069dab6a4b45df5c8d07 (patch)
tree731ac41b909295af30f5fa55c43418da2a0535e9 /lib
parentf1c6c5325b0f87af996d17fc7050c76ec8a754a7 (diff)
downloadpublic-inbox-e90a7953217879258cee069dab6a4b45df5c8d07.tar.gz
SpamAssassin queries URI blacklists, so it's probably OK
to enable this without being used as a linkfarm.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/View.pm8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index b09c3ba1..3bb38537 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -218,10 +218,17 @@ sub add_filename_line {
         "$pad " . ascii_html($fn) . " $pad\n";
 }
 
+my $LINK_RE = qr!\b((?:ftp|https?|nntp)://[@\w\+\&\?\.\%\;/#=-]+)!;
+
+sub linkify {
+        $_[0] =~ s!$LINK_RE!<a\nhref="$1"\n>$1</a>!g;
+}
+
 sub add_text_body_short {
         my ($enc, $part, $part_nr, $full_pfx) = @_;
         my $n = 0;
         my $s = ascii_html($enc->decode($part->body));
+        linkify($s);
         $s =~ s!^((?:(?:&gt;[^\n]*)\n)+)!
                 my $cur = $1;
                 my @lines = split(/\n/, $cur);
@@ -255,6 +262,7 @@ sub add_text_body_full {
         my ($enc, $part, $part_nr) = @_;
         my $n = 0;
         my $s = ascii_html($enc->decode($part->body));
+        linkify($s);
         $s =~ s!^((?:(?:&gt;[^\n]*)\n)+)!
                 my $cur = $1;
                 my @lines = split(/\n/, $cur);