Skip to content

fix: correct www autofix in no-bare-urls - #720

Open
tooth-is-silver wants to merge 5 commits into
eslint:mainfrom
tooth-is-silver:fix/no-bare-urls-www-autofix
Open

fix: correct www autofix in no-bare-urls#720
tooth-is-silver wants to merge 5 commits into
eslint:mainfrom
tooth-is-silver:fix/no-bare-urls-www-autofix

Conversation

@tooth-is-silver

@tooth-is-silver tooth-is-silver commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

What is the purpose of this pull request?

Fix the incorrect autofix for www autolinks.

What changes did you make? (Give an overview)

Updated no-bare-urls to convert www.example.com into [www.example.com](http://www.example.com).
Added a test for the autofix result.

Related Issues

Fixes #710

Is there anything you'd like reviewers to focus on?

Nothing in particular.

Disclosure: I'm a participant of open source contribution program OSSCA

@eslintbot eslintbot added this to Triage Aug 24, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage Aug 24, 2026
@tooth-is-silver tooth-is-silver changed the title fix: correct www autofix in no-bare-urls fix: correct www autofix in no-bare-urls Aug 24, 2026
@lumirlumir lumirlumir moved this from Needs Triage to Triaging in Triage Aug 25, 2026

@lumirlumir lumirlumir left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disclosure: I'm a participant of open source contribution program OSSCA: confirmed.

Thanks for the PR. I’ve left a few comments about incorrect autofix cases.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GFM allows any character other than whitespace and < after the domain, and Example 626 treats the following entire URL as a valid autolink:

Playground

www.google.com/search?q=(business))+ok

The current autofix produces:

[www.google.com/search?q=(business))+ok](http://www.google.com/search?q=(business))+ok)

When parsed again, the actual link destination is truncated to:

http://www.google.com/search?q=(business)

This happens because CommonMark requires parentheses in a link destination without angle brackets to be escaped or balanced. Similarly, after autofixing www.example.com/a\*b, the backslash is interpreted as a backslash escape, changing the URL to /a*b. In other words, the autofix silently changes valid URLs to different destinations.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another incorrect autofix behavior occurs when autofixing the following valid GFM input:

Playground

www.example.com/a]b

produces invalid link text:

[www.example.com/a]b](http://www.example.com/a]b)

I reproduced an issue where no-bare-urls throws Custom getRange() method must be implemented in the subclass during ESLint’s next autofix pass.

Additionally, after autofixing www.example.com/a*b*c and www.example.com/a~b~c, characters in the label are parsed as emphasis and strikethrough, respectively, changing the rendered output. The link text need to be escaped separately from the destination. CommonMark explicitly requires brackets within link text to be either backslash-escaped or part of a matched pair per the link text definition and Examples 528–529.

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

Projects

Status: Triaging

Development

Successfully merging this pull request may close these issues.

Bug: no-bare-urls autofix crashes for www autolinks

3 participants