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

Alex Vandiver alexmv at bestpractical.com
Sat May 3 01:29:51 EDT 2014


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

- Log -----------------------------------------------------------------
commit b3ca3d934889ff1e0f6f116ff98a0fc7b1f024b9
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.

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