Skip to content

Autolink: fix invalid string when email is followed by a multibyte character#812

Open
goulvench wants to merge 2 commits into
vmg:masterfrom
goulvench:autolink/fix-urls-followed-by-multibyte-characters
Open

Autolink: fix invalid string when email is followed by a multibyte character#812
goulvench wants to merge 2 commits into
vmg:masterfrom
goulvench:autolink/fix-urls-followed-by-multibyte-characters

Conversation

@goulvench

@goulvench goulvench commented Jun 3, 2026

Copy link
Copy Markdown

sd_autolink__email was using raw isalnum to detect email addresses, but isalnum can return true for non-ASCII bytes. This caused autolink to incorrectly capture trailing multibyte characters (e.g. contact@example.com中 would include the lead byte of 中 at the end of the email).

markdown.c already had a _isalnum helper that combines isalnum with an explicit c < 0x7f guard for exactly this reason. This PR moves that helper to autolink.h (which is included by both files via markdown.h) and uses it consistently in sd_autolink__email.

Fixes #811

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.

autolink returns invalid string when extracting a url followed by a multibyte character

1 participant