diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-11-11 12:38:52 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-11-11 12:38:52 -0800 |
commit | 58dd044ca1ea8316f4f4b6034eec12d204cc6913 (patch) | |
tree | 21baff7d2464d9fc5e54b4dcfcc3cfa9088d613f | |
parent | d4711bb865a17dcefb3b0907c0d452ef49c33c16 (diff) |
Don't allow link destinations with unbalanced unescaped parentheses.
See commonmark/commonmark.js#177.
-rw-r--r-- | src/inlines.c | 7 |
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; { |