Skip to content

fix: prevent SecurityError from external hash fragments on landing page#8025

Open
tenderdeve wants to merge 1 commit intoUniswap:mainfrom
tenderdeve:fix/7979-sanitize-hash-fragment
Open

fix: prevent SecurityError from external hash fragments on landing page#8025
tenderdeve wants to merge 1 commit intoUniswap:mainfrom
tenderdeve:fix/7979-sanitize-hash-fragment

Conversation

@tenderdeve
Copy link
Copy Markdown

When a URL like app.uniswap.org/#//example.org is opened, stripping the '#' leaves '//example.org' which React Router passes to history.replaceState. The browser rejects protocol-relative URLs from a different origin, throwing a SecurityError and showing the error overlay.

Only redirect when the resulting path starts with a single '/', which preserves all valid legacy hash routes like #/swap while ignoring external-looking fragments.

Fixes #7979

When a URL like app.uniswap.org/#//example.org is opened, stripping
the '#' leaves '//example.org' which React Router passes to
history.replaceState. The browser rejects protocol-relative URLs from
a different origin, throwing a SecurityError and showing the error overlay.

Only redirect when the resulting path starts with a single '/', which
preserves all valid legacy hash routes like #/swap while ignoring
external-looking fragments.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hash fragment redirects trigger “Something went wrong” error on Uniswap web landing page

1 participant