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

An invalid URI will make react-router crash #3507

Closed
pucka opened this issue Jun 2, 2016 · 5 comments
Closed

An invalid URI will make react-router crash #3507

pucka opened this issue Jun 2, 2016 · 5 comments

Comments

@pucka
Copy link

pucka commented Jun 2, 2016

Version

2.4.0

Test Case

http://codepen.io/anon/pen/VjYREm

Steps to reproduce

Use any non-valid UTF-8-encoded character sequence in the URI

Expected Behavior

This one is hard. I think you want react-router just to ignore the faulty values

Actual Behavior

react-router crashes making your site crash

@aweary
Copy link

aweary commented Jun 2, 2016

This error is thrown by the query-string which is used by history to parse URIs. Ignoring the faulty values in react-router would be dependent on that package being able to return the valid portions of the URI, as far as I can tell.

@pucka
Copy link
Author

pucka commented Jun 2, 2016

Yes, that's one of the two cases. The second case, when the pathname is invalid, the error is thrown in react routers PatternUtils using decodeURIComponent

@timdorr
Copy link
Member

timdorr commented Jun 2, 2016

You can provide your own query string parsing methods, which can work around this. It's really an upstream issue with query-string, so I would file an issue there.

@timdorr timdorr closed this as completed Jun 2, 2016
@pucka
Copy link
Author

pucka commented Jun 6, 2016

Ok, i'll do that. But it still breaks in react-routers own library @ https://github.com/reactjs/react-router/blob/master/modules/PatternUtils.js#L120 not related to query-string

May not be a case if you take care of this server side, but it's still breaks on client side.

@taion
Copy link
Contributor

taion commented Jun 6, 2016

Alternatively, catch the error and hit the error callback, as with #3453 – we'd be happy to accept a PR that does that (if it works, &c.)

@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants