my ($self, $s) = @_;
$s =~ s!$LINK_RE!
my $url = $1;
+ my $end = '';
+
+ # it's fairly common to end URLs in messages with
+ # '.' or ';' to denote the end of a statement.
+ if ($url =~ s/(\.)\z// || $url =~ s/(;)\z//) {
+ $end = $1;
+ }
+
# salt this, as this could be exploited to show
# links in the HTML which don't show up in the raw mail.
my $key = sha1_hex($url . $SALT);
# only escape ampersands, others do not match LINK_RE
$url =~ s/&/&/g;
$self->{$key} = $url;
- 'PI-LINK-'. $key;
+ 'PI-LINK-'. $key . $end;
!ge;
$s;
}
--- /dev/null
+# Copyright (C) 2016 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+use strict;
+use warnings;
+use Test::More;
+use PublicInbox::Linkify;
+
+{
+ my $l = PublicInbox::Linkify->new;
+ my $u = 'http://example.com/url-with-trailing-period';
+ my $s = $u . '.';
+ $s = $l->linkify_1($s);
+ $s = $l->linkify_2($s);
+ is($s, qq(<a\nhref="$u">$u</a>.), 'trailing period not in URL');
+}
+
+{
+ my $l = PublicInbox::Linkify->new;
+ my $u = 'http://example.com/url-with-trailing-semicolon';
+ my $s = $u . ';';
+ $s = $l->linkify_1($s);
+ $s = $l->linkify_2($s);
+ is($s, qq(<a\nhref="$u">$u</a>;), 'trailing semicolon not in URL');
+}
+
+done_testing();