-
Notifications
You must be signed in to change notification settings - Fork 959
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
LocationUtils should not run pathname through decodeURI #786
Comments
decodeURI decodes paths in a very strange way. This should hopefully solve remix-run#786. This will need to be coupled with a PR in react-router remix-run/react-router#6578.
Agreed, this line is breaking things for me too. This is the cause of remix-run/react-router#6578 and might be blocking it? I've done a PR, but I'm a novice at Github and this project so I guess.. we'll see what happens. |
FYI this broke use of the library for us as well. We had customers reporting some bug that we thought was something we were doing wrong, and it went unfixed for months until I finally figured it out and made a fork that removed that line and the error handling. |
@project707 we ended up using https://webpack.js.org/plugins/normal-module-replacement-plugin/ to replace the impacted file, but still be able to use the normal build of react-router and other files of history. Just comment out this part of history.js.
You do have to do additional work at the other end to decode your params, but I've just routed through a single component.
Hopefully this helps other people who find this issue. I believe its no longer an issue in react-router 6. |
https://github.com/ReactTraining/history/blob/master/modules/LocationUtils.js#L36
I have the following pathname:
:a/:b where a and b can contain symbols (so long as they are encoded)
Example:
This example gives me the expected, valid path:
go%2Fod/b%25ad
.However, when this path is used in
history
,createLocation('go%2Fod/b%25ad', ...irrelevant)
, it gets incorrectly mutated by line 36 and becomesgo%2Fod/b%ad
, becausedecodeURI
replaces %25 with % but does not replace %2F with /.The path is not
go%2Fod/b%ad
, and this causes the path to later be incorrectly parsed where%ad
is a URI encoded character instead of a string literal.What is the reason for decodeURI here and how is it accurate?
While I am encountering this error at a higher level (React Router DOM), the error seems to be in this package.
The text was updated successfully, but these errors were encountered: