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
net/url: no way to parse absolute URLs #16822
Comments
I'm not sure there's anything to fix here. Go interprets the scheme per the spec;
Which doesn't include "_". But the part of the spec you cite regarding not ignoring parts on error would apply if we had a function to just parse an absolute URL only. We don't, though: our Parse function is defined (for better or worse) to parse either absolute or relative paths. And if it's not a valid absolute URL, we have no choice but to interpret it as a possible valid relative path. Maybe we should add a way to parse in absolute mode only, in which case we could return an error. It still doesn't help you parse "cache_object" bogus schemes. |
Like I said I expect an error, because of the underscore. Ah. That it would parse relative URLs did not occur to me, but it's even documented. I'm not sure I'm reading this section 3.3 right:
The way I read this "cache_object:" is the first path segment, and thus violates section 3.3. (without throwing an error in the Go implementation). Apologies if I'm misreading. |
They are an artefact of squid and can't be parsed by net/url. Filed golang/go#16822 about it.
Looking at the code, (*URL).String gets this right, so we should probably fix Parse. Sent CL 31582. |
CL https://golang.org/cl/31582 mentions this issue. |
The behavior changed in 1.8. See also the 1.8 release notes[1], this Go issue[2], and these examples[3]. [1]https://golang.org/doc/go1.8#minor_library_changes [2]golang/go#16822 [3]https://play.golang.org/p/EKOP85WqLd
The behavior changed in 1.8. See also the 1.8 release notes[1], this Go issue[2], and these examples[3]. [1]https://golang.org/doc/go1.8#minor_library_changes [2]golang/go#16822 [3]https://play.golang.org/p/EKOP85WqLd
The behavior changed in 1.8. See also the 1.8 release notes[1], this Go issue[2], and these examples[3]. [1]https://golang.org/doc/go1.8#minor_library_changes [2]golang/go#16822 [3]https://play.golang.org/p/EKOP85WqLd
The behavior changed in 1.8. See also the 1.8 release notes[1], this Go issue[2], and these examples[3]. [1]https://golang.org/doc/go1.8#minor_library_changes [2]golang/go#16822 [3]https://play.golang.org/p/EKOP85WqLd
The behavior changed in 1.8. See also the 1.8 release notes[1], this Go issue[2], and these examples[3]. [1]https://golang.org/doc/go1.8#minor_library_changes [2]golang/go#16822 [3]https://play.golang.org/p/EKOP85WqLd
#1. What version of Go are you using (
go version
)?go version go1.7 linux/arm
#2. What operating system and processor architecture are you using (
go env
)?#3. What did you do?
https://play.golang.org/p/W4T12uL3_L
"cache_object" scheme is used by the squid proxy.
#4. What did you expect to see?
RFC3986 section 3.1:
I expect to get an error. I.e. for the play.golang.org snippet to panic.
#5. What did you see instead?
"Path" is set to the whole input.
The text was updated successfully, but these errors were encountered: