zig icon indicating copy to clipboard operation
zig copied to clipboard

std.Uri fails to parse on empty authority section so breaks file:/// scheme parsing

Open buzmeg opened this issue 2 years ago • 2 comments

The "authority" section of a URL is allowed to be empty. In particular if the URL scheme is "file://", the authority section is expected to be empty.

This is a bug: https://github.com/ziglang/zig/blob/6218e4004608000ba2e42e07ed1bd56745626820/lib/std/Uri.zig#L126

Thanks.

buzmeg avatar Mar 07 '23 00:03 buzmeg

Relevant portions of rfc3986 (as far as I can tell):

3.2. Authority

...

If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character. Non- validating parsers (those that merely separate a URI reference into its major components) will often ignore the subcomponent structure of authority, treating it as an opaque string from the double-slash to the first terminating delimiter, until such time as the URI is dereferenced.

3.2.2. Host

...

For example, the "file" URI scheme is defined so that no authority, an empty host, and "localhost" all mean the end-user's machine, whereas the "http" scheme considers a missing authority or empty host invalid.

(and for completeness, here's the file scheme RFC: https://www.rfc-editor.org/rfc/rfc8089)

cc @MasterQ32

squeek502 avatar Mar 07 '23 11:03 squeek502

Fixed in #14603

Vexu avatar Mar 07 '23 12:03 Vexu

Fix landed in c07d6e4c17ab555250e75bd053d27fd7df20f928.

andrewrk avatar Sep 29 '23 07:09 andrewrk