Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
buzmeg opened this issue Mar 7, 2023 · 3 comments
Labels
bug Observed behavior contradicts documented or intended behavior standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@buzmeg
Copy link

buzmeg commented Mar 7, 2023

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:

if (authority.len == 0)

Thanks.

@squeek502
Copy link
Collaborator

squeek502 commented Mar 7, 2023

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

@Vexu
Copy link
Member

Vexu commented Mar 7, 2023

Fixed in #14603

@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior standard library This issue involves writing Zig code for the standard library. labels Mar 7, 2023
@Vexu Vexu added this to the 0.11.0 milestone Mar 7, 2023
@andrewrk andrewrk modified the milestones: 0.11.0, 0.11.1 Jul 20, 2023
@andrewrk
Copy link
Member

Fix landed in c07d6e4.

@andrewrk andrewrk modified the milestones: 0.11.1, 0.12.0 Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

No branches or pull requests

4 participants