Skip to content

fix: pop drive-letter lookalike segment for non-file schemes (#2794) - #3217

Merged
nikneym merged 1 commit into
lightpanda-io:mainfrom
pasmud:gaz/lightpanda-io-browser-url-fix
Sep 5, 2026
Merged

fix: pop drive-letter lookalike segment for non-file schemes (#2794)#3217
nikneym merged 1 commit into
lightpanda-io:mainfrom
pasmud:gaz/lightpanda-io-browser-url-fix

Conversation

@pasmud

@pasmud pasmud commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #2794: new URL('..', 'abc://x/y/z/C:/') must resolve to abc://x/y/z/ but rust-url refuses to pop the trailing C: segment.

Root cause

rust-url 2.5.8's last_slash_can_be_removed applies the Windows-drive-letter exemption to every scheme when shortening a path with .., but per the WHATWG URL Standard that exemption only applies to file:. For any other scheme a C:/C| segment is ordinary and must be popped. The upstream fix (servo/rust-url#1138) is open but unmerged, so this adds an in-repo workaround.

Change

  • src/html5ever/url.rs: new fix_drive_letter_join helper, called from all four join/resolve FFI entry points (url_parse_with_base, url_join, url_resolve_without_encoding, url_resolve_with_encoding). When the base path ends with a drive-letter lookalike segment (/X:/ or /X|/) on a non-file scheme and the relative input starts with .., it pops that segment from the joined URL.
  • src/browser/URL.zig: Zig test for the resolve path covering the WPT case plus the http variant, the C| form, control segments, the no-trailing-slash case, and the file: guard.

Verification

  • cargo test --lib in src/html5ever: 4/4 pass (join cases, file guard, parse-with-base path, lookalike matcher).
  • zig fmt --check src/browser/URL.zig: clean.
  • Full zig build test could not run in this sandbox: the build fetches V8 + dependencies from GitHub, which the sandbox proxy/DNS rejects (HttpConnectionClosing/TemporaryNameServerFailure). The behavior was verified end-to-end via the Rust crate tests plus a raw probe of rust-url (abc://x/y/z/C:/ + .. returns the buggy abc://x/y/z/C:/ before the fix, abc://x/y/z/ after).

@krichprollsch

Copy link
Copy Markdown
Member

Thanks for your contribution.
I saw there is also an open PR on rust-url to fix the issue: servo/rust-url#1138
What about waiting for the merge?

@krichprollsch
krichprollsch requested a review from nikneym August 18, 2026 15:19
@nikneym

nikneym commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Hi & thank you for your contribution. We were actually hoping if servo/rust-url#1138 be merged so I'd like to keep this open for a little more and take action if it won't be fixed in the upstream.

@pasmud
pasmud force-pushed the gaz/lightpanda-io-browser-url-fix branch from 50fc0cc to 61395b7 Compare August 27, 2026 09:40
…nda-io#2794)

rust-url treats a trailing 'C:'/'C|' path segment as a Windows drive
letter when shortening a path with '..', for every scheme. Per the URL
Standard that exemption only applies to file:. Work around it in the
Rust binding (fix pending upstream in servo/rust-url#1138) so that
new URL('..', 'abc://x/y/z/C:/') resolves to 'abc://x/y/z/'.
@nikneym
nikneym force-pushed the gaz/lightpanda-io-browser-url-fix branch from 61395b7 to 04e2584 Compare September 4, 2026 15:05
@nikneym
nikneym merged commit 14d8684 into lightpanda-io:main Sep 5, 2026
25 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

url-constructor: '..' against a non-special base must pop the last path segment

3 participants