Optionally replace +
in parseUrlencoded
#62
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR provides a way to optionally replace
+
by space in query values before passing them to uri decoding. (I want to reemphasize importance of this change, so I'm coping here my arguments frompurescript-uri
issue).Without this option hyper user is not able to distinguish
+
from%2B
in original query as both are decoded to+
and finally is not able parse text input values containing spaces send by all tested by me modern browsers.I've tested on two versions of Firefox and Chromium (latest Firefox nightly 59.0a1 (2017-11-20), Chromium 62.0.3202.89 and Firefox 56.0.2) that this form:
results in + in queries (so we get "value+with+spaces"). The same behavior is observed when I add explicit enctype=application/x-www-form-urlencoded.
I know that this is not a real argument for discussion, but other libs/tools/frameworks do seem to decode
+
as space in query strings:Haskell http-types (Servant uses http-api-data which uses http-types):
parseQuery calls two times
urlDecode
withTrue
as the first argument:https://github.com/aristidb/http-types/blob/master/Network/HTTP/Types/URI.hs#L136
urlDecode
:https://github.com/aristidb/http-types/blob/master/Network/HTTP/Types/URI.hs#L206
Haskell Snap framework decodes
+
in query keys and values to space:https://github.com/snapframework/snap-core/blob/master/src/Snap/Internal/Parsing.hs#L368
Python3
urllib.parse
decodes+
in queries (even in strict mode ;-)):https://github.com/python/cpython/blob/3.6/Lib/urllib/parse.py#L697
Javascript
query-string
repalces+
in query keys and values:https://github.com/sindresorhus/query-string/blob/master/index.js#L148