Parsing of IPv6 addresses seems to incorrectly include `[]`s
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 406
- PR merge metrics
- No merged PRs in 30d
Description
- Note that this crate implements the URL Standard not RFC 1738 or RFC 3986
Describe the bug
Hi all!
It seems like parsing a URL that contains an IPv6 address like http://[::1] returns a Url struct that, when .host().unwrap.to_string() is called on it, returns [::1] where the docs state, for Host:
An IPv6 address. Url::host_str returns the serialization of that address between [ and ] brackets, in the format per RFC 5952 A Recommendation for IPv6 Address Text Representation: lowercase hexadecimal with maximal :: compression.
The "between" language here makes me think that it should not be including the [].
According to the linked URL Standard, it also states, for host parsing, that:
If input starts with U+005B ([), then:
If input does not end with U+005D (]), validation error, return failure.
Return the result of IPv6 parsing input with its leading U+005B ([) and trailing U+005D (]) removed.
Which makes it seem like the [] should be removed.
I'm just curious to get more clarity on expected behavior here.
This came up due to some confusion in https://github.com/nats-io/nats.rs/pull/386
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Url::host(), Url::host_str(), and Host::to_string() behavior for the input http://[::1], then compare it with the linked URL Standard and Host documentation. Add or update a regression test for the IPv6 host representation; done means the implementation, documentation, and test agree on whether brackets are included.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100