- Commit
- 67619a5d5c71c44565a9a0413aaf78f9baece528
- Parent
- 9253c0eab573e5ca0d37e4b1db77d3b0bfcf3be6
- Author
- John MacFarlane <jgm@berkeley.edu>
- Date
Disallow bracketed labels nested more than 1000 deep.
For performance reasons. See #166.
My personal build of CMark ✏️
Disallow bracketed labels nested more than 1000 deep.
For performance reasons. See #166.
1 file changed, 3 insertions, 2 deletions
Status | File Name | N° Changes | Insertions | Deletions |
Modified | src/inlines.c | 5 | 3 | 2 |
diff --git a/src/inlines.c b/src/inlines.c @@ -594,7 +594,8 @@ static int link_label(subject* subj, chunk *raw_label) advance(subj); // advance past [ unsigned char c; - while ((c = peek_char(subj)) && (c != ']' || nestlevel > 0)) { + while ((c = peek_char(subj)) && + (c != ']' || (nestlevel > 0 && nestlevel < STACK_LIMIT))) { switch (c) { case '`': tmp = handle_backticks(subj); @@ -622,7 +623,7 @@ static int link_label(subject* subj, chunk *raw_label) advance(subj); } } - if (c == ']') { + if (nestlevel == 0 && c == ']') { *raw_label = chunk_dup(&subj->input, startpos + 1, subj->pos - (startpos + 1)); subj->label_nestlevel = 0; advance(subj); // advance past ]