diff options
author | Eric Wong <e@80x24.org> | 2019-04-18 23:49:42 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-04-18 23:50:32 +0000 |
commit | e55bef366b87ecbcb66c93669f41876afc1d2446 (patch) | |
tree | d074edb75087809cae2c656d3f75166d404a89fc /lib/PublicInbox/Linkify.pm | |
parent | f94c3a195a25a31d0215cd175938008fca473378 (diff) | |
download | public-inbox-e55bef366b87ecbcb66c93669f41876afc1d2446.tar.gz |
Dangling parentheses with trailing punctuation usually means the parentheses is not intended as part of the URL.
Diffstat (limited to 'lib/PublicInbox/Linkify.pm')
-rw-r--r-- | lib/PublicInbox/Linkify.pm | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/PublicInbox/Linkify.pm b/lib/PublicInbox/Linkify.pm index 71193bc2..d4778e7d 100644 --- a/lib/PublicInbox/Linkify.pm +++ b/lib/PublicInbox/Linkify.pm @@ -47,8 +47,16 @@ sub linkify_1 { if ($url =~ s/$re//) { $end = $1; } - } elsif ($url =~ s/([\.,;])\z//) { - $end = $1; + } elsif ($url =~ s/(\))?([\.,;])\z//) { + $end = $2; + # require ')' to be paired with '(' + if (defined $1) { # ')' + if (index($url, '(') < 0) { + $end = ")$end"; + } else { + $url .= ')'; + } + } } elsif ($url !~ /\(/ && $url =~ s/\)\z//) { $end = ')'; } |