diff options
author | lpsolit%gmail.com <> | 2008-10-21 09:04:09 +0200 |
---|---|---|
committer | lpsolit%gmail.com <> | 2008-10-21 09:04:09 +0200 |
commit | 87462d261811e78b9b2c8e82425c19e26b6c2e53 (patch) | |
tree | 6e82e0a34537542caa01b50729621ab932fc980b /Bugzilla | |
parent | 27dfcceb519392c4014649d10b00d936adaf0daa (diff) | |
download | bugzilla-87462d261811e78b9b2c8e82425c19e26b6c2e53.tar.gz bugzilla-87462d261811e78b9b2c8e82425c19e26b6c2e53.tar.xz |
Bug 105865: When converting bug/attachment/comment numbers to links, quoteUrls() should take care of newlines and not linkify them if a newline is present - Patch by Frédéric Buclin <LpSolit@gmail.com> r/a=mkanat
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Template.pm | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index dbf52a97b..3f7205ca7 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -158,7 +158,7 @@ sub get_format { # If you want to modify this routine, read the comments carefully sub quoteUrls { - my ($text, $curr_bugid) = (@_); + my ($text, $curr_bugid, $already_wrapped) = (@_); return $text unless $text; # We use /g for speed, but uris can have other things inside them @@ -173,6 +173,10 @@ sub quoteUrls { my $chr1 = chr(1); $text =~ s/\0/$chr1\0/g; + # If the comment is already wrapped, we should ignore newlines when + # looking for matching regexps. Else we should take them into account. + my $s = $already_wrapped ? qr/\s/ : qr/\h/; + # However, note that adding the title (for buglinks) can affect things # In particular, attachment matches go before bug titles, so that titles # with 'attachment 1' don't double match. @@ -227,7 +231,7 @@ sub quoteUrls { ("\0\0" . ($count-1) . "\0\0") ~egmx; - $text =~ s~\b(attachment\s*\#?\s*(\d+)) + $text =~ s~\b(attachment$s*\#?$s*(\d+)) ~($things[$count++] = get_attachment_link($2, $1)) && ("\0\0" . ($count-1) . "\0\0") ~egmxi; @@ -240,9 +244,9 @@ sub quoteUrls { # Also, we can't use $bug_re?$comment_re? because that will match the # empty string my $bug_word = get_text('term', { term => 'bug' }); - my $bug_re = qr/\Q$bug_word\E\s*\#?\s*(\d+)/i; - my $comment_re = qr/comment\s*\#?\s*(\d+)/i; - $text =~ s~\b($bug_re(?:\s*,?\s*$comment_re)?|$comment_re) + my $bug_re = qr/\Q$bug_word\E$s*\#?$s*(\d+)/i; + my $comment_re = qr/comment$s*\#?$s*(\d+)/i; + $text =~ s~\b($bug_re(?:$s*,?$s*$comment_re)?|$comment_re) ~ # We have several choices. $1 here is the link, and $2-4 are set # depending on which part matched (defined($2) ? get_bug_link($2,$1,$3) : @@ -541,10 +545,10 @@ sub create { css_class_quote => \&Bugzilla::Util::css_class_quote , quoteUrls => [ sub { - my ($context, $bug) = @_; + my ($context, $bug, $already_wrapped) = @_; return sub { my $text = shift; - return quoteUrls($text, $bug); + return quoteUrls($text, $bug, $already_wrapped); }; }, 1 |