From 7767b22ab12aa4ab43ae389771617078248a4b84 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 4 Jun 2015 12:59:48 +0200 Subject: Don't allow link labels with no non-whitespace characters. See jgm/CommonMark#322. --- src/inlines.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/inlines.c b/src/inlines.c index 232fc10..352ded3 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -755,6 +755,7 @@ static int link_label(subject* subj, cmark_chunk *raw_label) if (c == ']') { // match found *raw_label = cmark_chunk_dup(&subj->input, startpos + 1, subj->pos - (startpos + 1)); + cmark_chunk_trim(raw_label); advance(subj); // advance past ] return 1; } @@ -1111,7 +1112,7 @@ int cmark_parse_reference_inline(cmark_strbuf *input, cmark_reference_map *refma subject_from_buf(&subj, input, NULL); // parse label: - if (!link_label(&subj, &lab)) + if (!link_label(&subj, &lab) || lab.len == 0) return 0; // colon: -- cgit v1.2.3