diff options
author | Koosha KM <koosha.khajeh@gmail.com> | 2014-09-05 14:37:03 +0000 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2014-09-05 14:37:03 +0000 |
commit | 6024c5cd0553bb9884d81f3d93b78f666b433d9e (patch) | |
tree | 5b20bb1e5f0ef14ec3ec0947ebd0923c389986a5 | |
parent | cf8e842b30edbdd20fc37487d7194efbd55ff2c0 (diff) | |
download | bugs-6024c5cd0553bb9884d81f3d93b78f666b433d9e.tar bugs-6024c5cd0553bb9884d81f3d93b78f666b433d9e.tar.gz bugs-6024c5cd0553bb9884d81f3d93b78f666b433d9e.tar.bz2 bugs-6024c5cd0553bb9884d81f3d93b78f666b433d9e.tar.xz bugs-6024c5cd0553bb9884d81f3d93b78f666b433d9e.zip |
Bug 1060308: Markdown: URLs and Emails are not rendered literally in code spans and code blocks
r=glob,a=sgreen
-rw-r--r-- | Bugzilla/Markdown.pm | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Bugzilla/Markdown.pm b/Bugzilla/Markdown.pm index c5a34fb6e..6cbe0f6c4 100644 --- a/Bugzilla/Markdown.pm +++ b/Bugzilla/Markdown.pm @@ -47,6 +47,7 @@ our %g_escape_table; foreach my $char (split //, '\\`*_{}[]()>#+-.!~') { $g_escape_table{$char} = md5_hex($char); } +$g_escape_table{'<'} = md5_hex('<'); sub new { my $invocant = shift; @@ -149,7 +150,7 @@ sub _StripLinkDefinitions { sub _DoAutoLinks { my ($self, $text) = @_; - $text =~ s{(?:<|<)((?:https?|ftp):[^'">\s]+)(?:>|>)}{<a href="$1">$1</a>}gi; + $text =~ s{(?:<|<)((?:https?|ftp):[^'">\s]+?)(?:>|>)}{<a href="$1">$1</a>}gi; return $text; } @@ -406,8 +407,11 @@ sub _EncodeCode { # In other words, html_quote() will change '>' to '&gt;' and then we will # change '&gt' -> '>' -> '>' if we write this substitution as the first one. $text =~ s/&/&/g; + $text =~ s{<a \s+ href="(?:mailto:)? (.+?)"> \1 </a>}{$1}xmgi; $text = $self->SUPER::_EncodeCode($text); $text =~ s/~/$g_escape_table{'~'}/go; + # Encode '<' to prevent URLs from getting linkified in code spans + $text =~ s/</$g_escape_table{'<'}/go; return $text; } @@ -426,6 +430,7 @@ sub _UnescapeSpecialChars { $text = $self->SUPER::_UnescapeSpecialChars($text); $text =~ s/$g_escape_table{'~'}/~/go; + $text =~ s/$g_escape_table{'<'}/</go; return $text; } |