Skip to content

reject line endings in pointy-bracket link destinations - #637

Merged
jgm merged 1 commit into
commonmark:masterfrom
zayeem06:pointy-url-line-ending
Oct 10, 2026
Merged

jgm merged 1 commit into
commonmark:masterfrom
zayeem06:pointy-url-line-ending

Conversation

@zayeem06

@zayeem06 zayeem06 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

The spec says a pointy-bracket link destination cannot contain a line ending, even one that is preceded by a backslash, but manual_scan_link_url in src/inlines.c advances two bytes on any backslash without looking at the next byte, so a backslash right before a newline makes the scan jump over the line ending and keep going on the next line. That lets cmark accept e.g.

[a](<b\
c>)

as a link whose destination spans two lines, while the reference parser (and the "destination cannot contain line endings" rule at spec.txt:7596) treats it as plain text. The fix only consumes the escape when the next byte exists and isn't a newline, otherwise the scan fails, which lines up with the newline check already sitting in the same loop. Reviewers may want to confirm the escaped-> case ([a](<b\>c>)) still parses as a link, which it does. Added a regression case to test/regression.txt that fails before the change and passes after.

@jgm
jgm merged commit 067e1fd into commonmark:master Oct 10, 2026
15 checks passed
@jgm

jgm commented Oct 10, 2026

Copy link
Copy Markdown
Member

good, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants