]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1214310: Markdown code blocks can display comments from other bugs
authorAlbert Ting <altlist@gmail.com>
Mon, 26 Oct 2015 19:43:52 +0000 (20:43 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Mon, 26 Oct 2015 19:43:52 +0000 (20:43 +0100)
r=dylan

Bugzilla/Markdown.pm

index 9c675099ba041f3fb282183a9b324e9edb2d71da..5ca37df28c8a59e71248d4c0ac921321bc2bf099 100644 (file)
@@ -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);