]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1518350 - Allow literal html tags to stand for themselves
authorDylan William Hardison <dylan@hardison.net>
Tue, 8 Jan 2019 15:06:15 +0000 (10:06 -0500)
committerGitHub <noreply@github.com>
Tue, 8 Jan 2019 15:06:15 +0000 (10:06 -0500)
Bugzilla/Markdown.pm

index 6a69694d4f6dcee3c7dc17a45251eecbe1e4da1f..c90772fcaf3ceae2de7519fd8f67a7e3c7ff4b57 100644 (file)
@@ -44,11 +44,17 @@ sub render_html {
   my $parser = $self->markdown_parser;
   return escape_html($markdown) unless $parser;
 
+  no warnings 'utf8'; # this is needed because our perl is so old.
+  # This is a bit faster since it doesn't engage the regex engine.
+  # Replace < with \x{FDD4}, and remove \x{FDD4}.
+  $markdown =~ tr/<\x{FDD4}/\x{FDD4}/d;
   my @valid_text_parent_tags = ('p', 'li', 'td');
   my @bad_tags               = qw( img );
   my $bugzilla_shorthand     = $self->bugzilla_shorthand;
   my $html                   = decode('UTF-8', $parser->render_html($markdown));
-  my $dom                    = Mojo::DOM->new($html);
+
+  $html =~ s/\x{FDD4}/&lt;/g;
+  my $dom = Mojo::DOM->new($html);
 
   $dom->find(join(', ', @bad_tags))->map('remove');
   $dom->find(join ', ', @valid_text_parent_tags)->map(sub {