summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-06-02 16:33:02 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-06-02 16:33:30 +0200
commit6ec3b485c406bb05ca5e13fe61d84df6b27f1945 (patch)
tree7fe4d4c5ff47f483bd1ccb37ea99212c414c736d
parent14ea489f5dd6e3d07e23f104d6c9ce441d05751b (diff)
Properly handle backslashes in link destinations.
Only ascii punctuation characters are escapable, per the spec. Closes #192.
-rw-r--r--src/inlines.c4
-rw-r--r--test/regression.txt8
2 files changed, 11 insertions, 1 deletions
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
<p><a href="te%3Cst">a</a></p>
````````````````````````````````
+Issue #192 - escaped spaces in link destination
+
+
+```````````````````````````````` example
+[a](te\ st)
+.
+<p>[a](te\ st)</p>
+````````````````````````````````