Skip to content

Conversation

vezaynk
Copy link
Contributor

@vezaynk vezaynk commented Mar 17, 2025

Some tooling might pass arbitrary strings in the window.location.hash. React Router should not crash if the value is not decodable.

In our case, for example, a user interacted with a URL that Datadog injected some tracking info into and the call turned to:

decodeURIComponent("targetindividualusers---input-raw%20:9999%20--output-http%20OVERRIDE_TARGET|OVERRIDE_PERCENT%%20--http-rewrite-url%20v5/onboarding:v6/interstitials%20--http-set-header%20X-Datadog-Parent-Id:%20--http-set-header%20X-Datadog-Trace-Id:%20--http-set-header%20X-Datadog-Sampling-Priority:1%20--http-allow-url%20/content/v5/onboarding")

...which crashed the view with the following error:

Uncaught URIError: malformed URI sequence 

To avoid this in the future, I would like to suggest that a failure to decode the portion of the URL be preventing from throwing, by wrapping in a try-catch.

Copy link

changeset-bot bot commented Mar 17, 2025

🦋 Changeset detected

Latest commit: 6551f5d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
react-router Patch
@react-router/architect Patch
@react-router/cloudflare Patch
@react-router/dev Patch
react-router-dom Patch
@react-router/express Patch
@react-router/node Patch
@react-router/serve Patch
@react-router/fs-routes Patch
@react-router/remix-routes-option-adapter Patch
create-react-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Mar 17, 2025

Hi @vezaynk,

Welcome, and thank you for contributing to React Router!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run.

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Mar 17, 2025

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@vezaynk vezaynk marked this pull request as ready for review March 17, 2025 22:30
@timdorr timdorr changed the base branch from main to dev June 26, 2025 19:08
@timdorr
Copy link
Member

timdorr commented Jun 26, 2025

This needs to be based against the dev branch, per our contribution guidelines: https://github.com/remix-run/react-router/blob/main/docs/community/contributing.md I updated the branch on the PR. Can you rebase and force-push to update on your end?

@vezaynk
Copy link
Contributor Author

vezaynk commented Jun 26, 2025

@timdorr Done!

@vezaynk
Copy link
Contributor Author

vezaynk commented Jun 26, 2025

@timdorr Could this get a ✅? This fixes a real bug for my team.

@vezaynk
Copy link
Contributor Author

vezaynk commented Jun 26, 2025

@timdorr Does this PR need anything else to be merged? It looks like merging is restricted to members only. 😁

@timdorr
Copy link
Member

timdorr commented Jun 27, 2025

Just a review by a core team member, as per our governance policy: https://github.com/remix-run/react-router/blob/main/GOVERNANCE.md#bugissue-process

@brophdawg11
Copy link
Contributor

Could you add a changeset?

@vezaynk
Copy link
Contributor Author

vezaynk commented Jul 7, 2025

@brophdawg11 Done!

@brophdawg11 brophdawg11 merged commit bfba2da into remix-run:dev Jul 7, 2025
5 checks passed
@MichaelDeBoey MichaelDeBoey changed the title Do not throw if the url hash is not a valid URI component fix(react-router): don't throw if the url hash is not a valid URI component Jul 7, 2025
Copy link
Contributor

🤖 Hello there,

We just published version 7.7.0-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 7.7.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

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