Skip to content

Keep URL host removal state and path offsets consistent - #1180

Open
omrzk wants to merge 1 commit into
servo:mainfrom
omrzk:fix/remove-host-state
Open

omrzk wants to merge 1 commit into
servo:mainfrom
omrzk:fix/remove-host-state

Conversation

@omrzk

@omrzk omrzk commented Nov 7, 2026

Copy link
Copy Markdown

set_host(None) removes the serialized authority but leaves the previous host kind behind. With an empty path followed by a query or fragment it also panics in debug builds, and removing a host before a // path turns that path into a new authority when reparsed.

Clear the host state, keep a root path when necessary, and preserve an empty first path segment with the existing /. representation. Query/fragment offsets, credentials and port removal stay consistent with the serialization. Adding a host back also removes the synthetic /. prefix, keeping the actual // path intact.

Fixes #1175.

Validation: four removal regressions fail on current main and pass with the fix; another host-prefix regression fails before the shared setter correction. The 72 URL unit tests and complete workspace default, serde/expose_internals and no-default-features/alloc suites pass. All-targets build, workspace strict Clippy and formatting checks pass. Tests cover domain/IPv4/IPv6 authorities, repeated removal and replacement, file URLs, existing rejection rules, empty paths and serialization round trips.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

set_host(None) keeps the old host, and can panic

1 participant