Skip to content

net/url: file URL with Windows path not parsed correctly #11223

@dgolub

Description

@dgolub

The Parse function in the net/url package does not properly handle a file URL with a Windows path. It should place the entire local path after the file:// in the Path field on the URL object, as on Unix/Linux, but it does not. If the path is specified entirely using backslashes, then it will be placed in the Host field. If it is specified using forward slashes or some combination of backslashes and forward slashes, then the portion before the first forward slash will be placed in the Host field and the remainder will be placed in the Path field. For example, the URL file://C:\Windows\System32\kernel32.dll parses to {Host: "C:\Windows\System32\kernel32.dll"} and the URL file://C:\Windows\System32/kernel32.dll parses to {Host: "C:\Windows\System32", Path: "/kernel32.dll"}. They should instead parse to {Path: "C:\Windows\System32\kernel32.dll"} and {Path: "C:\Windows\System32/kernel32.dll"}, respectively.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions