-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
querystring.parse expands "+" always, regardless of the parser #21841
Comments
The decoder functions ( |
Not sure you understood --
Fundamentally, "+" signs should not be decoded by querystring.parse() |
It does use
That's debatable, but that would be changing behavior that has existed for the past 6 years, unless the change is incorporated in a backwards-compatible way (e.g. opt-in in some way). |
Using the following two documents as reference:
From the docs:
The documentation doesn't mention query string handling of "+", it does mention that you can override the behavior of the decoder. When you override the decoder, you still have the same behavior. |
This is the key phrase from the documentation I believe (emphasis mine):
|
In this instance, we're not dealing with percent-encoded characters, but rather the unfortunately ambiguous "+" character. I will agree that RFC3986 section 2.2 says that "+" should be percent-encoded, I would offer that |
The current behavior matches the HTML Living Standard. Browsers submit forms using |
If we encode a string with encodeURIComponent() , It should be okay. But if we gives querystring.parse("C++") then it produce "C ". Which is acceptable it terms of html standards. What do you think ? |
I read the above discussion and it seems like an expected behavior written in the querystring's documentation as @mscdex mentioned.
In more detail, querystring.unescape works as same as decodeURIComponent which is the same behavior with whatwg's URL. // decodeURIComponent converts `%20` to an empty string
decodeURIComponent('%20') // => " "
// whatwg-url has the same behavior:
Object.fromEntries(new URLSearchParams('email=test+recipent')) // => {email: "test recipent"} Closing as resolved for now, but feel free to reopen when anyone has a point. Thank you. |
The "+" is always decoded in a query string, you can note the behavior difference in the example below. Using the internal parser an "external" parser and the parser directly yield results that are different.
The text was updated successfully, but these errors were encountered: