-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: semicolons treated as invalid characters in query string #50034
Comments
cc @FiloSottile |
Adding from the rfc: https://datatracker.ietf.org/doc/html/rfc3986#section-2.2
where
note Given that |
No version of Go ever produced what you expect to see:
Go 1.16 and earlier produces this:
The change in semicolon behavior was chosen to prevent mishandling of invalid queries while diverging as little as possible from earlier Go behavior. See #25192 (comment). |
@ianlancetaylor you are correct, but under no circumstance would I as a user expect the current behavior. That is, it was wrong, and it's still wrong....but worse, because now data is gone, and my logs are flooded. |
@ianlancetaylor to your point though, I did mis-attribute the current situation with #25192 -- they're not strictly related. Please forgive the mistake, I'm a bit frustrated at the whole thing, and perhaps wrote up the issue in a bit of haste (and with doubt that anything would come of it) They are somewhat tangentially related in that
when facing the two issues above, and seeing that go now either errors out (if using |
In an effort to stay engaged and productive on this - I have a couple questions:
While informative, @ianlancetaylor 's response didn't really give any direction on the issue |
I'm not closely involved with this issue. That said, Go pays a lot of attention to backward compatibility. If we completely change the handling of semicolons in the net/url and net/http packages, then it seems to me that we risk silently changing the behavior of existing Go programs. It seems to me that that might open up security holes, which would be bad. Can you address your specific issue by taking the URL string and converting Whether that helps or not, please don't expect any quick resolutions here. It's hard to find paths that work for as many people as possible. |
The current behavior was the least-bad option in a minefield, and it's motivated by trying to minimize the situations in which parser mis-alignment between a proxy and an application leads to security vulnerabilities. As mentioned in #49399 we'll remove the log line now that it has done its job, which was alerting applications of potential breakage. That should solve the issue for anyone who's not parsing the query but just forwarding RawQuery. Anyone who wants the pre-Go 1.17 behavior can opt-in with AllowQuerySemicolon. The only thing that's not addressed is applications that wish to parse unencoded semicolons as non-separators. Are there a lot of clients that send unescaped semicolons expecting them to NOT be handled as separators? If yes, maybe we could add a EscapeQuerySemicolon Handler?
|
@FiloSottile I work with a lot of really wacky urls. I'm certain that there are some clients that will send unescaped semicolons expecting them not to be separators. I invite you to engage with my proposal for adding a query parsing interface (#56300). URL parsing has been shown to be very sensitive to change. It's also something that keeps cropping up in different areas, such as In the The challenges have lead me to believe the best way forward is to provide interfaces, and provide a safe and sane default implementation. Let users that have particular needs supply their own, so they can get consistent behavior across the various http libraries without worrying about the next go release subtly changing behavior. |
@FiloSottile just as an example of something probably pretty common:
Follow the redirect to get the full URL, here's what's returned by Google:
(Found my way here after upgrading a service running some ancient Go to 1.21). |
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?
Parsed a url with a non url-encoded semicolon in a value of a query string parameter
https://go.dev/play/p/n68WBqiRmkt
What did you expect to see?
The value parsed literally, and successfully - e.g.,
What did you see instead?
There have been a number of issues related to the new semicolon handling (some of which raised by myself):
The original issue, and proposal to add
AllowQuerySemicolons
:It's not clear why the current behavior has been chosen. The oringal issue only highlighted semicolons as an issue as a seperator. The current implementation ignores them entirely -- which is incredibly frustrating.
The fact of the matter is that urls containing raw semicolons do exist and those parameter values have meaning.
I'd really appreciate if we could have a dialog about potential options. I'm willing to invest time to do any implementation, but it's not clear to me what the powers that be will find acceptable.
As it stands, the issues introduced by the url parsing change in 1.17 has prevented upgrades at my org. I'd really like to help find a safe & viable way forward
The text was updated successfully, but these errors were encountered: