Skip to content

autolink: three cmark-gfm parity fixes - #833

Closed
YuEfSaEDU wants to merge 1 commit into
kivikakk:mainfrom
YuEfSaEDU:fix/autolink-cmark-gfm-parity
Closed

YuEfSaEDU wants to merge 1 commit into
kivikakk:mainfrom
YuEfSaEDU:fix/autolink-cmark-gfm-parity

Conversation

@YuEfSaEDU

Copy link
Copy Markdown

With extension.autolink enabled, comrak diverged from cmark-gfm in three cases (#832).

url_match now calls check_domain with allow_short = 1 as cmark-gfm does, so dot-less hosts such as http://localhost/x autolink again (they did through 0.43.0; the requirement of a dot dates to #618), while a new check mirroring the host-character test in sd_autolink_issafe keeps bare http:// from linking; http://user:pass@host/ is likewise matched whole instead of falling through to the email matcher.

The scheme is now compared case-insensitively, matching sd_autolink_issafe, so HTTP://www.example.com/ autolinks while www. matching stays case-sensitive.

Finally, the autolink matchers consult the bracket stack rather than a flag cleared by any ], mirroring cmark_inline_parser_in_bracket, so an inner ] no longer lets an autolink run through an enclosing link or produce an <a> nested inside an <a>. Fixture tests are added for each case.

With extension.autolink enabled, three cases diverged from
cmark-gfm (kivikakk#832).

url_match now calls check_domain with allow_short = 1, as
cmark-gfm does, so a dot-less host such as http://localhost/x
autolinks again (as it did up to 0.43.0; changed in kivikakk#618). As
in sd_autolink_issafe, the first character after the scheme
must be a valid host character, so a bare http:// still does
not autolink. http://user:pass@host/ is now matched as a whole
instead of falling through to the email matcher.

The scheme is compared case-insensitively, as in
sd_autolink_issafe, so HTTP://www.example.com/ autolinks;
www. matching stays case-sensitive.

The autolink matchers consult the bracket stack rather than a
flag cleared by any ], matching cmark_inline_parser_in_bracket:
an autolink is refused anywhere inside an open bracket, so an
inner ] no longer lets an autolink run through an enclosing
link, producing a link inside a link.
@kivikakk

kivikakk commented Sep 8, 2026

Copy link
Copy Markdown
Owner

This user does not appear to be submitting human-authored patches; closing per CONTRIBUTING.

IMG_1534

@kivikakk kivikakk closed this Sep 8, 2026
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.

3 participants