X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLinkify.pm;h=274f38209fa3a2c1a880b20a2c9c28a4a94e603a;hb=3d41aa23f35501ca92aab8aa42980fa73f7fa74f;hp=8e1728c71136c78de06af4d53603e54116496edb;hpb=d9e9c8ed84a15c7fdf8fa57e82fcec9de7ecba87;p=public-inbox.git
diff --git a/lib/PublicInbox/Linkify.pm b/lib/PublicInbox/Linkify.pm
index 8e1728c7..274f3820 100644
--- a/lib/PublicInbox/Linkify.pm
+++ b/lib/PublicInbox/Linkify.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2016 all contributors
+# Copyright (C) 2014-2018 all contributors
# License: AGPL-3.0+
# two-step linkification.
@@ -25,7 +25,7 @@ my $LINK_RE = qr{(\()?\b((?:ftps?|https?|nntps?|gopher)://
sub new { bless {}, $_[0] }
sub linkify_1 {
- $_[1] =~ s!$LINK_RE!
+ $_[1] =~ s^$LINK_RE^
my $beg = $1 || '';
my $url = $2;
my $end = '';
@@ -41,6 +41,8 @@ sub linkify_1 {
}
} elsif ($url =~ s/([\.,;])\z//) {
$end = $1;
+ } elsif ($url !~ /\(/ && $url =~ s/\)\z//) {
+ $end = ')';
}
# salt this, as this could be exploited to show
@@ -51,7 +53,7 @@ sub linkify_1 {
$url =~ s/&/&/g;
$_[0]->{$key} = $url;
$beg . 'PI-LINK-'. $key . $end;
- !ge;
+ ^ge;
$_[1];
}