From d5a6c485f52429cf6b1b18da3c4f47e2adc6edfc Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 1 May 2016 01:54:07 +0000 Subject: linkify: match more URL characters [:,\$] and schemes Adding ':' (colon), ',' (comma), '$' (dollar sign) and supporting TLS-enabled schemes: ftps, nntps variants as well as gopher :D --- lib/PublicInbox/Linkify.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/Linkify.pm b/lib/PublicInbox/Linkify.pm index 49ab3116..25f0b48a 100644 --- a/lib/PublicInbox/Linkify.pm +++ b/lib/PublicInbox/Linkify.pm @@ -15,9 +15,9 @@ use warnings; use Digest::SHA qw/sha1_hex/; my $SALT = rand; -my $LINK_RE = qr!\b((?:ftp|https?|nntp):// +my $LINK_RE = qr!\b((?:ftps?|https?|nntps?|gopher):// [\@:\w\.-]+/ - ?[~\@\w\+\&\?\.\%\;/#=-]*)!x; + ?[,:~\$\@\w\+\&\?\.\%\;/#=-]*)!x; sub new { bless {}, shift } @@ -28,8 +28,10 @@ sub linkify_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//) { + # '.', ',' or ';' to denote the end of a statement; + # assume the intent was to end the statement/sentence + # in English + if ($url =~ s/([\.,;])\z//) { $end = $1; } -- cgit v1.2.3-24-ge0c7