From 281440598ea947cfb9cacda034566a6e7bbe590e Mon Sep 17 00:00:00 2001 From: Albert Ting Date: Mon, 26 Oct 2015 20:43:52 +0100 Subject: Bug 1214310: Markdown code blocks can display comments from other bugs r=dylan --- Bugzilla/Markdown.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Markdown.pm b/Bugzilla/Markdown.pm index 9c675099b..5ca37df28 100644 --- a/Bugzilla/Markdown.pm +++ b/Bugzilla/Markdown.pm @@ -18,8 +18,6 @@ use Digest::MD5 qw(md5_hex); use parent qw(Text::MultiMarkdown); -@Bugzilla::Markdown::EXPORT = qw(new); - # Regex to match balanced [brackets]. See Friedl's # "Mastering Regular Expressions", 2nd Ed., pp. 328-331. our ($g_nested_brackets, $g_nested_parens); @@ -44,7 +42,6 @@ $g_nested_parens = qr{ }x; our %g_escape_table; -my @code_blocks; foreach my $char (split //, '\\`*_{}[]()>#+-.!~') { $g_escape_table{$char} = md5_hex($char); @@ -82,6 +79,12 @@ sub _Markdown { return $self->SUPER::_Markdown($text, @_); } +sub _code_blocks { + my ($self) = @_; + $self->{code_blocks} = $self->{params}->{code_blocks} ||= []; + return $self->{code_blocks}; +} + sub _RunSpanGamut { # These are all the transformations that occur *within* block-level # tags like paragraphs, headers, and list items. @@ -122,7 +125,7 @@ sub _removeFencedCodeBlocks { ) `{3,} [\s\t]* $ }{ - push @code_blocks, $1; + push @{$self->_code_blocks}, $1; "%%%FENCED_BLOCK%%%"; }egmx; return $text; @@ -410,7 +413,7 @@ sub _DoCodeBlocks { $text =~ s{ ^ %%%FENCED_BLOCK%%% }{ - my $codeblock = shift @code_blocks; + my $codeblock = shift @{$self->_code_blocks}; my $result; $codeblock = $self->_EncodeCode($codeblock); -- cgit v1.2.3-24-g4f1b