net/url: Parse thinks /// does not start an authority #46277
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/eDpmB6DyF_f
What did you expect to see?
I expected the following URL to be parsed:
This is since the first two slashes in
///threeslashes
should start the host, while only the last slash belongs to the path.What did you see instead?
There's actually a test case for this in net/url already:
go/src/net/url/url_test.go
Lines 212 to 223 in 6c1c055
The comment says that "Three leading slashes isn't an authority." But it is. RFC 3986 gives the following definition:
We see that
authority
can absolutely be the empty string. In fact, url.Parse no longer returns an error if the Host is empty, so the comment is moot.The comment also says that ReadRequest depends on the url.Parse code path. However, this is not correct: it now uses url.ParseRequestURI, which does correctly parse the original URL as
Path: "///threeslashes"
.The text was updated successfully, but these errors were encountered: