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.
Rationale
This addresses #10814 by switching from using
safelyDecodeURI()
to usingsafelyDecodeURIComponent()
inmatchRoutes()
. The reason usingdecodeURIComponent
is necessary is because it does not assume is is operating on a full URI. From MDN:The result is when
decodeURI
it can lead to portions of the string not being decoded properly.Example
This example shows what is currently happening when
decodeURI
is used and is borrowed from #11109:Then navigate to the following URL:
/bad%20%26%20encoding%20%25%20here
Expected: The parameter should be decoded and
"bad & encoding % here"
is logged.Actual: The parameter is not decoded properly and
"bad %26 encoding % here"
is logged.This PR fixes this and adds regression tests.
Changes
matchRoutes()
utility to usesafelyDecodeURIComponent()
.pathname
once rather than per call tomatchRouteBranch
as thepathname
does not change.safelyDecodeURIComponent
to optionally take theparamName
argument.safelyDecodeURI
as this utility is no longer used. Happy to walk this back if the maintainers feel different about leaving code like this around.