hyperium / hyperium/http

URI parser cannot parse URNs

Open
#379 4 comments 6 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

It seems the URI parser stumbles with URNs. A simple test to reproduce:

fn main() {
    use http::uri::Uri;
    let uri = "urn:isbn:1238492".parse::<Uri>();
    println!("{:?}", uri);
}

Produces the output:

$ ./testcase
Err(InvalidUri(InvalidAuthority))

The authority is only present when the scheme is followed by //, otherwise the parser should be parsing everything after the first : as the path. Python gets this right, and Go parses this as Opaque (instead of Host, but still successfully parses):

Python:

>>> urlparse('urn:isbn:0451450523')
ParseResult(scheme='urn', netloc='', path='isbn:0451450523', params='', query='', fragment='')

Go:

>>> url, _ := url.Parse("urn:isbn:0451450523")
>>> fmt.Println("Host (Opaque):", url.Opaque)
Host (Opaque): isbn:0451450523

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 Rust http::uri::Uri parsing entry point and reproduce the provided urn:isbn:1238492 example. Compare the parser's behavior with the stated URI rule and the Python and Go results. Done means a URN parses successfully and the text after the first colon is handled as path or opaque content rather than an invalid authority.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.