From: Dylan William Hardison Date: Wed, 16 Jan 2019 21:39:54 +0000 (-0500) Subject: Bug 1519564 followup - ensure there are never newlines in html attributes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff1dd75d851c0a7c4d4843eff92bb2035cac0ecd;p=thirdparty%2Fbugzilla.git Bug 1519564 followup - ensure there are never newlines in html attributes --- diff --git a/Bugzilla/Markdown.pm b/Bugzilla/Markdown.pm index 069368701..6c7b06ecc 100644 --- a/Bugzilla/Markdown.pm +++ b/Bugzilla/Markdown.pm @@ -51,6 +51,15 @@ sub render_html { if ($markdown =~ /^\s*$MARKDOWN_OFF\n/s) { my $text = $self->bugzilla_shorthand->( trim($markdown) ); + my $dom = Mojo::DOM->new($text); + $dom->find('*')->each(sub { + my ($e) = @_; + my $attr = $e->attr; + foreach my $key (keys %$attr) { + $attr->{$key} =~ s/\s+/ /gs; + } + }); + $text = $dom->to_string; my @p = split(/\n{2,}/, $text); my $html = join("\n", map { s/\n/
\n/gs; "

$_

\n" } @p ); return $html;