fix: reject GFM email autolink when the domain ends in _ or - - #4063
Open
contactjawad wants to merge 1 commit into
Open
fix: reject GFM email autolink when the domain ends in _ or -#4063contactjawad wants to merge 1 commit into
contactjawad wants to merge 1 commit into
Conversation
The GFM inline url rule's email pattern used a trailing `(?![-_])` lookahead, which let the regex give back the final domain character when the domain was followed by `_` or `-`, truncating the last label and producing a wrong `mailto:` target. Per the GFM spec a domain must not end in `_`/`-`; use a `(?![\w-])` lookahead so the domain matches maximally and the autolink fails cleanly (rendered as plain text) in that case.
|
@contactjawad is attempting to deploy a commit to the MarkedJS Team on Vercel. A member of the Team first needs to authorize it. |
This was referenced Aug 21, 2026
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
UziTech
requested changes
Aug 23, 2026
Member
There was a problem hiding this comment.
Can you remove this test and add a test in https://github.com/markedjs/marked/tree/master/test/specs/new?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The GFM email autolink rule mangles an address when its domain is immediately followed by
_or-.The
emailsub-pattern in the GFM inlineurlrule ends with a(?![-_])lookahead. Since that only forbids-/_after the final domain character, the regex backtracks and gives that character back to satisfy the lookahead — truncating the last domain label and producing a wrongmailto:target plus a visibly split word (e.g.foo@bar.com-autolinksfoo@bar.coand leavesm-behind).Per the GFM spec a domain label must not end in
_or-. Changing the lookahead to(?![\w-])also forbids a following word character, forcing the final label to match maximally; when the maximal domain is then followed by_/-, the whole autolink fails and the text is rendered as-is — which is the correct behaviour.Added a unit test covering
foo@bar.com_andfoo@bar.com-, both of which now tokenize as plain text. It fails onmasterand passes with this change.