hyperium / hyperium/http

Uri does not parse valid URIs with empty authority portion

Open
#696 3 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.4k
Forks
378
Avg merge
1d 21h
Merged PRs (30d)
5

Description

Per RFC 3986, a valid URI may contain an empty authority (via an empty reg-name). However, it does not parse correctly by the Uri type:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=54db213feefae8e5b47294b4fcdbdad7

[src/main.rs:6:5] "file:///a/b/c".parse::<Uri>() = Err(
    InvalidUri(
        InvalidFormat,
    ),

Similarly, from_parts complains specifically that the authority is missing:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=0d31ed893d7f6cb8b37df6353eecfe8a

[src/main.rs:11:5] Uri::from_parts(parts) = Err(
    InvalidUriParts(
        InvalidUri(
            AuthorityMissing,
        ),
    ),

I could look into a change here, but note this fix would also be a breaking behavior change, and if any users are intentionally using this to enforce a non-empty authority, then they would be impacted.

cc @seanmonstar @LucioFranco - thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Uri parser and Uri::from_parts entry points described in the issue, and compare their behavior with RFC 3986's empty authority rule. Reproduce both provided examples, then add focused coverage showing the intended handling and confirming the resulting parsing and parts-construction behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.