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

[Bug]: Incorrect Handling of Double-Encoded URL Parameters #11293

Open
polamoros opened this issue Feb 21, 2024 · 4 comments
Open

[Bug]: Incorrect Handling of Double-Encoded URL Parameters #11293

polamoros opened this issue Feb 21, 2024 · 4 comments
Labels

Comments

@polamoros
Copy link

polamoros commented Feb 21, 2024

What version of React Router are you using?

6.22.1

Steps to Reproduce

  • Define a dynamic route to capture branch names, using the pattern /:branch.
  • Encode a branch name that includes slashes (e.g., fix/my-awesome-fix): fix%2Fmy-awesome-fix
  • Encode the encoded branch name (needed to use it as a URL param): fix%252Fmy-awesome-fix

Expected Behavior

Handle the double-encoded parameter by decoding it once, transforming %252F back to %2F, and preserving the slash as encoded.

Actual Behavior

The double-encoded slash (%252F) in the branch name is decoded twice, converting it directly to /, which misrepresents the original branch name (fix/my-awesome-fix instead of fix%2Fmy-awesome-fix).

Anything else?

I was able to reproduce the issue on versions 6.19 and 6.20, so it's not related to #10814 (comment), which I initially thought might have been the cause.

@polamoros polamoros added the bug label Feb 21, 2024
@polamoros polamoros changed the title [Bug]: [Bug]: Incorrect Handling of Double-Encoded URL Parameters Feb 21, 2024
@skyrpex
Copy link

skyrpex commented Feb 21, 2024

Exactly. I don't fully understand why would the router decode the params until there's no special characters in it, instead of just decoding once.

@Zboule
Copy link

Zboule commented Mar 4, 2024

Issue reproduced in version 6.22.1

Could the URL be decoded only once ?

@dishu5312
Copy link

Facing same issue on version 6.22.1.

Any updates on this?

@almostintuitive
Copy link

Unfortunately we're bumping into this as well. Is there any potential fix?

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

No branches or pull requests

5 participants