[Rt-commit] rt branch, 4.2/makeclicky-close-paren, created. rt-4.2.3-185-g3323a4c

Alex Vandiver alexmv at bestpractical.com
Sat May 3 01:30:48 EDT 2014


The branch, 4.2/makeclicky-close-paren has been created
        at  3323a4c2fdcaa70271c2d4fd921aa68a907e1191 (commit)

- Log -----------------------------------------------------------------
commit 3323a4c2fdcaa70271c2d4fd921aa68a907e1191
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sat May 3 01:25:25 2014 -0400

    Only include closing paren if URL included an open paren
    
    Open and close paren characters are valid in links.  However, links are
    often placed in parenthetical statements, leading MakeClicky to
    incorrectly include the closing paren in the link -- which, when
    clicked, is thus often a 404.
    
    Use a heuristic to determine if a last-character closing paren is likely
    intended to be part of the link or not, based on if the link includes an
    open paren character.  This will allow both of the following links to
    still work as their writers likely intended:
    
         http://en.wikipedia.org/wiki/Fish_(disambiguation)
         (something like http://bestpractical.com/)
    
    This is, of course, a trade-off.  However, the ability to link to
    http://en.wikipedia.org/wiki/) is likely not a feature that will be
    missed.
    
    Fixes #29064.

diff --git a/share/html/Elements/MakeClicky b/share/html/Elements/MakeClicky
index 3d9024c..8bd4ecf 100644
--- a/share/html/Elements/MakeClicky
+++ b/share/html/Elements/MakeClicky
@@ -61,15 +61,19 @@ my %actions = (
     },
     url => sub {
         my %args = @_;
+        my $post = "";
+        $post = ")" if $args{value} !~ /\(/ and $args{value} =~ s/\)$//;
         $args{value} = $escaper->($args{value});
         my $result = qq{[<a target="new" href="$args{value}">}. loc('Open URL') .qq{</a>]};
-        return $args{value} . qq{ <span class="clickylink">$result</span>};
+        return $args{value} . qq{ <span class="clickylink">$result</span>$post};
     },
     url_overwrite => sub {
         my %args = @_;
+        my $post = "";
+        $post = ")" if $args{value} !~ /\(/ and $args{value} =~ s/\)$//;
         $args{value} = $escaper->($args{value});
         my $result = qq{<a target="new" href="$args{value}">$args{value}</a>};
-        return qq{<span class="clickylink">$result</span>};
+        return qq{<span class="clickylink">$result</span>$post};
     },
 );
 

-----------------------------------------------------------------------


More information about the rt-commit mailing list