-
Notifications
You must be signed in to change notification settings - Fork 960
Description
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:
encodeURIComponent('go/od') + '/' + encodeURIComponent('b%ad')
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 becomes go%2Fod/b%ad, because decodeURI 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.
<Link to={`/user/${encodeURIComponent('go/od')}/filter/${encodeURIComponent('b%ad')}`>view user go/od with filter b%ad</Link>
// becomes correct syntax:
<Link to="/user/go%2Fod/filter/b%25ad">view user go/od with filter b%ad</Link>
// /user/go%2Fod/filter/b%25ad <-- expected output href
// /user/go%2Fod/filter/b%ad <-- actual, unexpected output href