Repository navigation
Conversation
Nacl-HCl
force-pushed
the
fix-set-scheme-file-955
branch
from
November 9, 2026 02:31
3c5cfe2 to
3621d1e
Compare
Switching to the `file` scheme was rejected for every URL with an authority. Per the URL Standard it must only be rejected when the URL includes credentials or has a non-null port, and switching away from `file` must be rejected when the file URL's host is empty or null. The no-host guard also no longer treats `file` like the other special schemes, since `file` does not require a host. Fixes servo#955.
Nacl-HCl
force-pushed
the
fix-set-scheme-file-955
branch
from
November 12, 2026 10:59
3621d1e to
6fd7eb9
Compare
This branch has not been deployed
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.
Fixes #955.
Url::set_schemerejected every change to thefilescheme for URLs with anauthority (
new_scheme_type.is_file() && self.has_authority()), which does notmatch the URL Standard. Under the scheme-state override rules, switching to
filemust only be rejected when the URL includes credentials or has anon-null port, and switching away from
filemust be rejected when thefileURL's host is empty or null. The no-host guard below the checks alsotreated
filelike the other special schemes, even thoughfiledoes notrequire a host, which kept
fileURLs without a host from retaining thefilescheme.With this change:
Url::parse("file:///path/to/file.js")?.set_scheme("file")returnsOk(())(the case reported in The incorrect implementation of
set_schemeforfile://#955).http://localhost/foo(no credentials, no port) can switch tofile,while URLs with credentials or a port still cannot.
fileURL with an empty host still cannot switch to another scheme.Tests
Added regression tests in
url/tests/unit.rsfor switching tofilewithcredentials, switching to
filewithout a port or credentials, settingfileon a
fileURL, and switching away fromfilewith an empty and a non-emptyhost. Verified locally:
cargo test -p url— unit (72), WPT (67) and doc tests (67) all passcargo test --workspace— all passcargo clippy --workspace --all-targets -- -D warnings— cleancargo fmt --all --check— cleancargo +1.63.0 test -p url --test unitwithci-lockfiles/1.63.Cargo.lock— 72 passed (MSRV)