summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-06-04 12:59:48 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2015-06-04 12:59:48 +0200
commit7767b22ab12aa4ab43ae389771617078248a4b84 (patch)
treec615b02addfc074c1c34e86d98d0d12874ef45b2 /src
parent240400e1c397c6b379c0c7c21d1ec658dbb24153 (diff)
Don't allow link labels with no non-whitespace characters.
See jgm/CommonMark#322.
Diffstat (limited to 'src')
-rw-r--r--src/inlines.c3
1 files changed, 2 insertions, 1 deletions
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: