Skip to content

Commit 39ca0d9

Browse files
jgmkevinbackhouse
authored andcommitted
Fixed HTML comment scanning.
Need to handle this case: `<!--> and -->`. Since the scanner finds the longest match, we had to move some of the logic outside of the scanner.
1 parent 3716b6c commit 39ca0d9

File tree

4 files changed

+3567
-3614
lines changed

4 files changed

+3567
-3614
lines changed

src/inlines.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -909,10 +909,17 @@ static cmark_node *handle_pointy_brace(subject *subj, int options) {
909909
int c = subj->input.data[subj->pos];
910910
if (c == '!') {
911911
c = subj->input.data[subj->pos+1];
912-
if (c == '-') {
913-
matchlen = scan_html_comment(&subj->input, subj->pos + 1);
914-
if (matchlen > 0)
915-
matchlen += 1; // prefix "<!"
912+
if (c == '-' && subj->input.data[subj->pos+2] == '-') {
913+
if (subj->input.data[subj->pos+3] == '>') {
914+
matchlen = 4;
915+
} else if (subj->input.data[subj->pos+3] == '-' &&
916+
subj->input.data[subj->pos+4] == '>') {
917+
matchlen = 5;
918+
} else {
919+
matchlen = scan_html_comment(&subj->input, subj->pos + 1);
920+
if (matchlen > 0)
921+
matchlen += 1; // prefix "<"
922+
}
916923
} else if (c == '[') {
917924
if ((subj->flags & FLAG_SKIP_HTML_CDATA) == 0) {
918925
matchlen = scan_html_cdata(&subj->input, subj->pos + 2);

0 commit comments

Comments
 (0)