From 505d70a6e78c08dea5447339446f564c435d25ca Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 21 Oct 2019 08:28:20 -0700 Subject: [PATCH] Markdown.pl: allow documented single-quote ref titles The documentation claims that all of these work: [1]: url1.txt "title 1" [2]: url2.txt 'title 2' [3]: url3.txt (title 3) However, the single-quote version was not being accepted. Update the regular expression to grok the single-quote variant and require the correct matching closing quote in order to match. This corrects the invalid acceptance of mismatched quote titles such as "title) and (title". Signed-off-by: Kyle J. McKay --- Markdown.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Markdown.pl b/Markdown.pl index eb9bfce..3813b27 100755 --- a/Markdown.pl +++ b/Markdown.pl @@ -551,9 +551,9 @@ sub _StripLinkDefinitions { [ ]* (?: (?<=\s) # lookbehind for whitespace - ["(] - (.+?) # title = $3 - [")] + (?:(['"])|(\()) # title quote char + (.+?) # title = $5 + (?(4)\)|\3) # match same quote [ ]* )? # title is optional (?:\n+|\Z) @@ -561,7 +561,7 @@ sub _StripLinkDefinitions { {}mx) { my $id = _strip(lc $1); # Link IDs are case-insensitive my $url = $2; - my $title = _strip($3); + my $title = _strip($5); $url =~ s/\\\n\s*//gs; if ($id ne "") { $g_urls{$id} = _EncodeAmpsAndAngles($url);