Browse Source

Markdown.pl: do not choke on <br></br> etc.

Adjust code to properly handle "empty" tags that are written as an open
plus closing tag but do not contain any whitespace in the opening tag.

The code already properly handles turning <hr noshade></hr> into
just <hr noshade="noshade" />, but it was failing to handle that
when the opening tag did not contain any whitespace such as <br></br>.

Adjust the code to return the proper value for the opening tag under
such a condition so that it's handled properly.

Previously a sequence such as <br></br> would fail as it would end
up being turned into <br /></br> which then fails XML validation.

Now it works properly and turns <br></br> into <br /> as it should
have been doing all along.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
master
Kyle J. McKay 4 years ago
parent
commit
35c983c9f0
  1. 3
      Markdown.pl

3
Markdown.pl

@ -3750,7 +3750,8 @@ sub _Sanitize {
my $tt = lc($1);
return ("&lt;" . substr($tag,1), 0) if $taga1p{$tt};
if ($tagmt{$tt}) {
return ("<" . $tt . $opt{empty_element_suffix}, 3);
my $typ = ($tag =~ m,/>$,) ? 3 : -3;
return ("<" . $tt . $opt{empty_element_suffix}, $typ);
} elsif ($tag =~ m,/>$,) {
return ("<" . $tt . "></" . $tt . ">", 3);
} else {

Loading…
Cancel
Save