Skip to content
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

Should we treat + as %20 in query part? #38

Closed
paluh opened this issue Nov 17, 2017 · 3 comments
Closed

Should we treat + as %20 in query part? #38

paluh opened this issue Nov 17, 2017 · 3 comments

Comments

@paluh
Copy link
Contributor

paluh commented Nov 17, 2017

I know that it is not compliant with RFC 3986 as it allows only percent encoding of special characters (and explicitly shows how to encode spaces), but unfortunately + is used as space encoding character in query part by many libraries and even browsers (based on RFC-1866 - first sentence in first section!) - situation is quite clearly described in this answer:

https://stackoverflow.com/questions/2678551/when-to-encode-space-to-plus-or-20#answer-47188851

After query decoding phase users of this library are not able to differentiate if + means really decoded %2B or literal + (which was incorrectly used), so maybe we should decode these incorrectly used pluses as %20 before passing query string to decodeURIComponent.

If you agree I can provide appropriate pull request with this change ;-)

@paluh
Copy link
Contributor Author

paluh commented Nov 20, 2017

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:

Also 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:

```
<!DOCTYPE html>
<html>
<body>
  <form action=".">
    <input name="name with spaces" value="value with spaces" />
    <input type="submit" value="send" />
  </form>
</body>
</html>
```

results in + in queries. The same behavior is observed when I add explicit enctype=application/x-www-form-urlencoded.

@paluh
Copy link
Contributor Author

paluh commented Dec 5, 2017

Sorry, I wasn't aware of this closed thread: #25

Should I close this issue?

@garyb
Copy link
Member

garyb commented Mar 20, 2018

The new version of the library doesn't fix this specifically, but it's now possible to solve it in a way that is more natural than having to do custom parsing/printing on the whole URI. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants