about summary refs log tree commit homepage
path: root/lib/PublicInbox/Linkify.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/Linkify.pm')
-rw-r--r--lib/PublicInbox/Linkify.pm12
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 = ')';
                 }