Skip to content

🐛 fix(url): read special links without slashes - #2295

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
gaborbernat:fix/url-special-whatwg-schemes
Nov 16, 2026
Merged

gaborbernat merged 2 commits into
tox-dev:mainfrom
gaborbernat:fix/url-special-whatwg-schemes

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

Node.resolve_links() returned a link whose special scheme differs from the base's as written when the link had no slash or one slash before its host, and returned a backslash in its path unchanged, so ftp:elsewhere.test/x and x\y did not resolve to the URL a browser opens (#2277). Fixes #2277. 🔗 Once this merges, such links resolve to the host and path a browser reads.

The link join read a special scheme's host only for an empty authority, and it took a backslash as a path character. The WHATWG URL parser reads the host after any run of slashes that follows a special scheme, zero or more of them (special authority slashes state, special authority ignore slashes state). It treats a backslash as a path separator in every special URL (special scheme), and it treats %2e in any case as a single-dot path segment (single-dot path segment).

The join now reads the host after those slashes for every special scheme except file, and merges the path with the same separator and dot-segment rules for every special base. The fast path that skips the join for absolute links sends a link through the join when the join would change it, such as a link with no slash before the host, a backslash, or an upper-case scheme. A reference that shares the base's scheme and has no authority stays relative.

Behavior changes

  • A special-scheme link with a different scheme, and with no slash or one slash before its host, resolves to the host it names.
  • A backslash in the path of such a link, and in a relative link under a special base, is a path separator.
  • %2e and %2e%2e in any case are dot segments in relative paths and in those rewritten links.
  • Absolute links the join leaves alone keep their path as written.
  • A link with no host after its slashes, such as ftp:/, stays as written.
  • Default ports are not removed, so ftp:h:21/p keeps :21.
  • Links with the file scheme keep the RFC 3986 reading.

resolve_links() and the document base returned a link whose special
scheme differed from the base's as written when it had no slash or a
single slash before the host, and returned a backslash in its path
unchanged. A browser reads the host after any run of slashes that
follows the scheme and treats a backslash as a path separator in a
special URL. The link join now does the same, resolving the path
segments, including %2e dot segments, the same way for every special
scheme except file. A reference that shares the base's scheme and has
no authority stays relative. Fixes tox-dev#2277.
@gaborbernat gaborbernat added the bug Something isn't working label Nov 16, 2026
@gaborbernat
gaborbernat merged commit 62c1534 into tox-dev:main Nov 16, 2026
1 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resolve_links keeps special-scheme links without slashes and backslash separators

1 participant