Skip to content

Keep the path prefix when a component contains a colon - #75

Closed
hossamradwaneg87-max wants to merge 1 commit into
chipsenkbeil:mainfrom
hossamradwaneg87-max:fix/normalize-windows-colon-component
Closed

hossamradwaneg87-max wants to merge 1 commit into
chipsenkbeil:mainfrom
hossamradwaneg87-max:fix/normalize-windows-colon-component

Conversation

@hossamradwaneg87-max

Copy link
Copy Markdown

normalize() drops the prefix, the root and everything before a component that contains a colon. C:\data\a:stream normalizes to a:stream and the path is no longer absolute. A UNC share and C:data\a:stream fail the same way.

The component is still a normal component. Pushing it goes back through the parser, which reads "a:" as a drive prefix and replaces the path with it. This appends the whole component instead, so the prefix stays in front.

The append goes through a new push_component method on Encoding and Utf8Encoding. Both traits are sealed so nothing outside the crate can implement them.

Tests cover the drive, UNC and drive-relative forms, the non-UTF-8 Windows path type, and that the result stays absolute.

Paths whose components do not parse with a prefix normalize as before.

normalize() dropped the prefix, the root and everything before a component containing a colon, because pushing that component went back through the parser and replaced the path with it. Append normal components directly instead.
@hossamradwaneg87-max

hossamradwaneg87-max commented Dec 5, 2026 •

Copy link
Copy Markdown
Author

Duplicate of #74, which has the same finding. Closing this one to keep it in a single thread.

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.

1 participant