-
Notifications
You must be signed in to change notification settings - Fork 18k
net/url: Parse does not permit percent escapes in host #30844
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
Comments
In addition, both "<" and ">" are allowed in host (specifically registered name) when they shouldn't be as per: https://tools.ietf.org/html/rfc3986#section-3.2.2 https://golang.org/src/net/url/url.go?s=2590:2650#L100 This should pct-encode the ">", but doesn't: |
@zombiezen I wrote a test with your expected result, and I got it passing by removing a check here: The note on the if branch mentions page 21 of that same RFC that you've linked: https://github.com/golang/go/blob/master/src/net/url/url.go#L215-L220 I think this is the relevant bit:
Also, I can see that the mention about RFC implementation by the package has been "relaxed" a while ago: https://go-review.googlesource.com/c/go/+/22859/ Not sure how to interpret the RFC, but happy to hear your thoughts. Also worth noticing that some tests are actually checking the opposite behaviour: |
@bradfitz, any thoughts on this issue? I remember there being some subtleties about what sort of changes we want to permit around |
Given that we String-ify such Hosts, I'm not opposed to trying to Parse them too. We'll see what breaks. But please send a change soon, as the freeze is coming, and net/url changes are notorious for breaking things & getting reverted. |
What's not entirely clear to me is:
The example of I've made a change, and I'll open a CL, but there were tests explicitly asserting the opposite of what this issue says, see:
Also the current comment on the if statement mentions:
Have a look at the changes. |
Change https://golang.org/cl/172157 mentions this issue: |
@bcmills @zombiezen RFC3986 says %-encoding is allowed in reg-name for only non-ASCII characters; If I'm interpreting this correctly, Should this issue be closed? If no, I would like to start working on a patch improving upon @thoeni's CL 172157 . |
In that case the encoding "/" as %2F is wrong? What code is responsible for that? (See testcase in opening msg) |
RFC 3986 permits percent-encoded characters in the host part of a URL.
*net/url.URL.String
will percent-encode thenet/URL.Host
field, but confusingly,url.Parse
does not accept URLs produced in this form.Applications like PostgreSQL that use
net/url.Parse
to parse URLs that have this form produce an error, see lib/pq#796. The prior #16127 notes some mismatch betweennet/url.Parse
and RFC 3986. This issue is around the specific issue of percent-encoded characters in the host, not any larger scope.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/l9oOmcNkYUd
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: