Skip to content

🐛 fix(url): resolve foreign special links to host - #2268

Merged
gaborbernat merged 5 commits into
tox-dev:mainfrom
gaborbernat:fix/url-special-empty-host
Nov 16, 2026
Merged

gaborbernat merged 5 commits into
tox-dev:mainfrom
gaborbernat:fix/url-special-empty-host

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

Node.resolve_links() returned a link with a different special scheme and extra slashes before its host, such as ftp:///example.com/p, exactly as written, so the resolved link named a host the browser would not open (#2250). Fixes #2250. 🔗 Once this merges, such links resolve to the host they name.

The link join read the host of a special-scheme reference only when the reference used the base's scheme. For a different scheme the join took the reference as absolute and returned it unchanged (RFC 3986 section 5.2.2), and the extract fast path skipped the join for the same reason (the old check at the merge base). A browser parses such a reference with the special authority rule, which does not depend on the base and skips every slash after the two that open the authority (special authority ignore slashes state).

The join now reads the host after the extra slashes for any special scheme other than file (the new check), and the fast path sends those references through the join (the new predicate).

Behavior changes

  • Node.resolve_links() resolves a link with a different special scheme and extra slashes to the host it names. Before, the link was returned as written.
  • A special-scheme reference with no host after its slashes, such as ftp:///, is still returned as written.
  • Links that already share the base's scheme, and links with a host directly after //, are unchanged.

A link whose scheme is a different special scheme from the base, with
extra slashes before its host, such as ftp:///host/path, came back from
resolve_links() exactly as written. A browser skips the extra slashes
and reads the host after them, so the link named a host the resolved
URL did not. The link join now reads that host for any special scheme
other than file, and the extract fast path sends such links through
the join. Fixes tox-dev#2250.
The bitwise test raised -Wparentheses under -Werror. Each slash test is now a parenthesized pair, so the outcome is unchanged.
@gaborbernat gaborbernat added the bug Something isn't working label Nov 16, 2026
@gaborbernat
gaborbernat merged commit 902b1eb 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 with extra slashes

1 participant