summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-11-11 12:38:52 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2019-11-11 12:38:52 -0800
commit58dd044ca1ea8316f4f4b6034eec12d204cc6913 (patch)
tree21baff7d2464d9fc5e54b4dcfcc3cfa9088d613f /src
parentd4711bb865a17dcefb3b0907c0d452ef49c33c16 (diff)
Don't allow link destinations with unbalanced unescaped parentheses.
See commonmark/commonmark.js#177.
Diffstat (limited to 'src')
-rw-r--r--src/inlines.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/inlines.c b/src/inlines.c
index e6b491f..d9301c8 100644
--- a/src/inlines.c
+++ b/src/inlines.c
@@ -439,8 +439,9 @@ static int scan_delims(subject *subj, unsigned char c, bool *can_open,
*can_close = right_flanking &&
(!left_flanking || cmark_utf8proc_is_punctuation(after_char));
} else if (c == '\'' || c == '"') {
- *can_open = left_flanking && !right_flanking &&
- before_char != ']' && before_char != ')';
+ *can_open = left_flanking &&
+ (!right_flanking || before_char == '(' || before_char == '[') &&
+ before_char != ']' && before_char != ')';
*can_close = right_flanking;
} else {
*can_open = left_flanking;
@@ -954,7 +955,7 @@ static bufsize_t manual_scan_link_url_2(cmark_chunk *input, bufsize_t offset,
}
}
- if (i >= input->len)
+ if (i >= input->len || nb_p != 0)
return -1;
{