From d0d83bb1c6ab60e7d7ea5e7730fdb2e008712d93 Mon Sep 17 00:00:00 2001 From: "bzrmirror%bugzilla.org" Date: Fri, 5 Sep 2014 14:45:46 +0000 Subject: [PATCH] Bug 1060308: Markdown: URLs and Emails are not rendered literally in code spans and code blocks r=glob,a=sgreen git-svn-id: svn://10.0.0.236/trunk@265549 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/.bzrrev | 2 +- mozilla/webtools/bugzilla/.gitrev | 2 +- mozilla/webtools/bugzilla/Bugzilla/Markdown.pm | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mozilla/webtools/bugzilla/.bzrrev b/mozilla/webtools/bugzilla/.bzrrev index 940c4c40de2..27432870ba7 100644 --- a/mozilla/webtools/bugzilla/.bzrrev +++ b/mozilla/webtools/bugzilla/.bzrrev @@ -1 +1 @@ -9121 \ No newline at end of file +9122 \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/.gitrev b/mozilla/webtools/bugzilla/.gitrev index 5e23eaf102f..03dd790477c 100644 --- a/mozilla/webtools/bugzilla/.gitrev +++ b/mozilla/webtools/bugzilla/.gitrev @@ -1 +1 @@ -cf8e842b30edbdd20fc37487d7194efbd55ff2c0 \ No newline at end of file +6024c5cd0553bb9884d81f3d93b78f666b433d9e \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/Bugzilla/Markdown.pm b/mozilla/webtools/bugzilla/Bugzilla/Markdown.pm index c5a34fb6e18..6cbe0f6c489 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Markdown.pm +++ b/mozilla/webtools/bugzilla/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]+)(?:>|>)}{$1}gi; + $text =~ s{(?:<|<)((?:https?|ftp):[^'">\s]+?)(?:>|>)}{$1}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{ \1 }{$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; }