Skip to content

Add regression test for entities in autolinks (#263) - #311

Merged
jgm merged 2 commits into
commonmark:masterfrom
cpruijsen:fix/issue-263
Sep 14, 2026
Merged

jgm merged 2 commits into
commonmark:masterfrom
cpruijsen:fix/issue-263

Conversation

@cpruijsen

Copy link
Copy Markdown
Contributor

Entities inside autolinks are left undecoded. The spec limits the exemption to code spans and code
blocks, so <http://example.com/?a=1&amp;b=2> should resolve the entity like any other inline
context, and currently does not.

parseAutolink in lib/inlines.js took the raw text between the angle brackets straight to
normalizeURI and to the link's text node. Both now go through decodeHTMLStrict first, which is the
same decoder the rest of the inline parser uses, so an autolink is consistent with the surrounding
text rather than being a quiet exception to it.

Both branches are changed, the email autolink and the general one, since the exemption applied to
neither.

A regression case covers an entity in each.

Fixes #263

Entity and numeric character references in autolinks were passed
through literally, so <http://&gt;> rendered as
<a href="http://&amp;gt;">. Decode entities in the destination and
the link label, matching cmark, which unescapes entities (but not
backslash escapes) in both.

Closes commonmark#263.
@jgm
jgm merged commit 49df475 into commonmark:master Sep 14, 2026
4 checks passed
@jgm

jgm commented Sep 14, 2026

Copy link
Copy Markdown
Member

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.

Entities inside autolinks not recognized

2 participants