From db23eb216ba3476ef502285a5f2d50134177ec91 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Wed, 29 Jan 2014 16:04:39 +0800 Subject: Bug 105865: bugzilla should pay attention to linebreaks when making bugnumbers to links --- Bugzilla/Template.pm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'Bugzilla/Template.pm') diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 81202965c..bf1254626 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -170,6 +170,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 = ($comment && $comment->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. @@ -236,8 +240,8 @@ sub quoteUrls { ~$1$2~igx; # attachment links - # BMO: Bug 652332 dkl@mozilla.com 2011-07-20 - $text =~ s~\b(attachment\s*\#?\s*(\d+)(?:\s+\[diff\])?(?:\s+\[details\])?) + # BMO: don't make diff view the default for patches (Bug 652332) + $text =~ s~\b(attachment$s*\#?$s*(\d+)(?:$s+\[diff\])?(?:\s+\[details\])?) ~($things[$count++] = get_attachment_link($2, $1, $user)) && ("\0\0" . ($count-1) . "\0\0") ~egmxi; @@ -250,14 +254,14 @@ sub quoteUrls { # Also, we can't use $bug_re?$comment_re? because that will match the # empty string my $bug_word = template_var('terms')->{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, { comment_num => $3, user => $user }) : "$1") - ~egox; + ~egx; # Old duplicate markers. These don't use $bug_word because they are old # and were never customizable. -- cgit v1.2.3-24-g4f1b