diff options
author | Byron Jones <glob@mozilla.com> | 2014-04-23 07:15:48 +0200 |
---|---|---|
committer | Byron Jones <glob@mozilla.com> | 2014-04-23 07:18:27 +0200 |
commit | 81deb32db9cb7f4ba46402e896fa3ef5497f25e1 (patch) | |
tree | a62939823a3173eadf48f11b04aa4056cd19cf95 /Bugzilla/Template.pm | |
parent | f05505e38e4d212dbf85c46a95b364f8852b54da (diff) | |
parent | 39412f01810dceff5ff92e6ffab03fb35ad71e7b (diff) | |
download | bugzilla-81deb32db9cb7f4ba46402e896fa3ef5497f25e1.tar.gz bugzilla-81deb32db9cb7f4ba46402e896fa3ef5497f25e1.tar.xz |
merged with bugzilla/4.2
Diffstat (limited to 'Bugzilla/Template.pm')
-rw-r--r-- | Bugzilla/Template.pm | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index b1bea78e5..d2d6a7dd1 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -162,13 +162,11 @@ sub quoteUrls { # (http://foo/bug#3 for example). Filtering that out filters valid # bug refs out, so we have to do replacements. # mailto can't contain space or #, so we don't have to bother for that - # Do this by escaping \0 to \1\0, and replacing matches with \0\0$count\0\0 - # \0 is used because it's unlikely to occur in the text, so the cost of - # doing this should be very small - - # escape the 2nd escape char we're using - my $chr1 = chr(1); - $text =~ s/\0/$chr1\0/g; + # Do this by replacing matches with \x{FDD2}$count\x{FDD3} + # \x{FDDx} is used because it's unlikely to occur in the text + # and are reserved unicode characters. We disable warnings for now + # until we require Perl 5.13.9 or newer. + no warnings 'utf8'; # If the comment is already wrapped, we should ignore newlines when # looking for matching regexps. Else we should take them into account. @@ -199,11 +197,11 @@ sub quoteUrls { $1, $2, $3, $4, $5, $6, $7, $8, $9, $10]})) - && ("\0\0" . ($count-1) . "\0\0")/egx; + && ("\x{FDD2}" . ($count-1) . "\x{FDD3}")/egx; } else { $text =~ s/$match/($things[$count++] = $replace) - && ("\0\0" . ($count-1) . "\0\0")/egx; + && ("\x{FDD2}" . ($count-1) . "\x{FDD3}")/egx; } } @@ -213,7 +211,7 @@ sub quoteUrls { Bugzilla->params->{'sslbase'})) . ')'; $text =~ s~\b(${urlbase_re}\Qshow_bug.cgi?id=\E([0-9]+)(\#c([0-9]+))?)\b ~($things[$count++] = get_bug_link($3, $1, { comment_num => $5, user => $user })) && - ("\0\0" . ($count-1) . "\0\0") + ("\x{FDD2}" . ($count-1) . "\x{FDD3}") ~egox; # non-mailto protocols @@ -221,7 +219,7 @@ sub quoteUrls { $text =~ s~\b($safe_protocols) ~($tmp = html_quote($1)) && ($things[$count++] = "<a href=\"$tmp\">$tmp</a>") && - ("\0\0" . ($count-1) . "\0\0") + ("\x{FDD2}" . ($count-1) . "\x{FDD3}") ~egox; # We have to quote now, otherwise the html itself is escaped @@ -243,7 +241,7 @@ sub quoteUrls { # 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") + ("\x{FDD2}" . ($count-1) . "\x{FDD3}") ~egmxi; # Current bug ID this comment belongs to @@ -273,9 +271,8 @@ sub quoteUrls { # Now remove the encoding hacks in reverse order for (my $i = $#things; $i >= 0; $i--) { - $text =~ s/\0\0($i)\0\0/$things[$i]/eg; + $text =~ s/\x{FDD2}($i)\x{FDD3}/$things[$i]/eg; } - $text =~ s/$chr1\0/\0/g; return $text; } |