cmark

My personal build of CMark ✏️

Commit
6ec3b485c406bb05ca5e13fe61d84df6b27f1945
Parent
14ea489f5dd6e3d07e23f104d6c9ce441d05751b
Author
John MacFarlane <jgm@berkeley.edu>
Date

Properly handle backslashes in link destinations.

Only ascii punctuation characters are escapable, per the spec.

Closes #192.

Diffstat

2 files changed, 11 insertions, 1 deletion

Status File Name N° Changes Insertions Deletions
Modified src/inlines.c 4 3 1
Modified test/regression.txt 8 8 0
diff --git 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
@@ -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>
+````````````````````````````````