summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorAlbert Ting <altlist@gmail.com>2015-10-26 20:43:52 +0100
committerFrédéric Buclin <LpSolit@gmail.com>2015-10-26 20:43:52 +0100
commit281440598ea947cfb9cacda034566a6e7bbe590e (patch)
treef3f2ad70be0c27b81b5c02802ce9175de42b27d4 /Bugzilla
parent197090f4d4b2f7c9971d28fc8b19a45d7ba245c2 (diff)
downloadbugzilla-281440598ea947cfb9cacda034566a6e7bbe590e.tar.gz
bugzilla-281440598ea947cfb9cacda034566a6e7bbe590e.tar.xz
Bug 1214310: Markdown code blocks can display comments from other bugs
r=dylan
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Markdown.pm13
1 files changed, 8 insertions, 5 deletions
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);