From: Dylan William Hardison Date: Tue, 8 Jan 2019 15:06:15 +0000 (-0500) Subject: Bug 1518350 - Allow literal html tags to stand for themselves X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4c5f80fe11377b0e2bcc95c41524340e59c3f6b;p=thirdparty%2Fbugzilla.git Bug 1518350 - Allow literal html tags to stand for themselves --- diff --git a/Bugzilla/Markdown.pm b/Bugzilla/Markdown.pm index 6a69694d4..c90772fca 100644 --- a/Bugzilla/Markdown.pm +++ b/Bugzilla/Markdown.pm @@ -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}/</g; + my $dom = Mojo::DOM->new($html); $dom->find(join(', ', @bad_tags))->map('remove'); $dom->find(join ', ', @valid_text_parent_tags)->map(sub {