From 6ec3b485c406bb05ca5e13fe61d84df6b27f1945 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 2 Jun 2017 16:33:02 +0200 Subject: Properly handle backslashes in link destinations. Only ascii punctuation characters are escapable, per the spec. Closes #192. --- src/inlines.c | 4 +++- test/regression.txt | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/inlines.c b/src/inlines.c index 021d5a3..eea0631 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -842,7 +842,9 @@ static bufsize_t manual_scan_link_url(cmark_chunk *input, bufsize_t offset) { } } else { while (i < input->len) { - if (input->data[i] == '\\') + if (input->data[i] == '\\' && + i + 1 < input-> len && + cmark_ispunct(input->data[i+1])) i += 2; else if (input->data[i] == '(') { ++nb_p; diff --git a/test/regression.txt b/test/regression.txt index ebc31bc..18b7d79 100644 --- a/test/regression.txt +++ b/test/regression.txt @@ -84,3 +84,11 @@ Issue #193 - unescaped left angle brackets in link destination

a

```````````````````````````````` +Issue #192 - escaped spaces in link destination + + +```````````````````````````````` example +[a](te\ st) +. +

[a](te\ st)

+```````````````````````````````` -- cgit v1.2.3