Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/inlines.c
Original file line number Diff line number Diff line change
Expand Up @@ -1102,9 +1102,15 @@ static bufsize_t manual_scan_link_url(cmark_chunk *input, bufsize_t offset,
if (input->data[i] == '>') {
++i;
break;
} else if (input->data[i] == '\\')
i += 2;
else if (input->data[i] == '\n' || input->data[i] == '<')
} else if (input->data[i] == '\\') {
// a backslash escape may cover the next character, but it cannot
// smuggle a line ending into the destination, which is forbidden
// inside pointy brackets.
if (i + 1 < input->len && input->data[i + 1] != '\n')
i += 2;
else
return -1;
} else if (input->data[i] == '\n' || input->data[i] == '<')
return -1;
else
++i;
Expand Down
10 changes: 10 additions & 0 deletions test/regression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,13 @@ break, not a paragraph.
<hr />
<p><a href="/url">foo</a></p>
````````````````````````````````

A pointy-bracket link destination may not contain a line ending, even
when the newline is preceded by a backslash.
```````````````````````````````` example
[a](<b\
c>)
.
<p>[a](&lt;b<br />
c&gt;)</p>
````````````````````````````````
Expand Down
Loading