net/url: ResolveReference does not respect ForceQuery #46033
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
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/VIk2U1Wflir
What did you expect to see?
https://timothygu.me/?
This is the behavior of Chrome, Firefox, Safari, Node.js (both legacy and modern parsers), curl, Rust's url crate, and Ruby's URI module.
What did you see instead?
https://timothygu.me/?hello
Here's what RFC 3986 said about this case:
where
R
is the parsed reference andT
is the resolved target. Currently, net/url usesRawQuery != ""
as the equivalent for "defined(R.query)". However, this does not take into account theForceQuery
flag added in Go 1.7, which should also satisfy "defined(R.query)".To be fair, Go's current behavior is consistent with Python. However, Python's urllib doesn't distinguish between
/?
and/
(i.e., it doesn't have a ForceQuery flag), so there's no way it can get this right.Discovered through my URL Tester tool: https://timothygu.me/urltester/
The text was updated successfully, but these errors were encountered: