From a3c4d34b752cdb97df434f811ee80f18430f0d46 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 3 Aug 2021 16:48:45 -0700 Subject: [PATCH] Markdown.pl: allow '/' in auto-quoted attribute values When auto-quoting the attribute value of something like this: test Do not stop at the first "/", instead pick up the entire value. Of course, whitespace will still terminate the value being auto-quoted. Additionally, when checking the end of the tag to see if it's self-closing (e.g. "
") do not include the final character of any value that may have been picked up by the auto-quoting process. For the example above, that prevents the opening "a" tag from mistakenly being considered self-closing just because the value being auto-quoted happens to end in a "/" and butts right up against the final ">" of the tag. Signed-off-by: Kyle J. McKay --- Markdown.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Markdown.pl b/Markdown.pl index f466be1..23b0053 100755 --- a/Markdown.pl +++ b/Markdown.pl @@ -3791,7 +3791,7 @@ sub _Sanitize { ++$atc; next; } - if ($tag =~ /\G([^\s<\/>]+)\s*/gcs) { + if ($tag =~ m{\G([^\s<>]+)\s*}gcs) { # auto quote it my $v = $1; $v =~ s/\042/"/go; @@ -3807,11 +3807,11 @@ sub _Sanitize { $out =~ s/\s+$//; my $typ = 1; if ($tagmt{$tt}) { - $typ = ($tag =~ m,/>$,) ? 3 : -3; + $typ = ($sfx =~ m,/>$,) ? 3 : -3; $out .= $opt{empty_element_suffix}; return ("<" . substr($tag,1), 0) if !$atc && $taga1p{$tt}; } else { - if ($tag =~ m,/>$,) { + if ($sfx =~ m,/>$,) { return ("<" . substr($tag,1), 0) if !$atc && $taga1p{$tt}; $typ = 3; } else {