Skip to content

v1.1.1 breaks routing with encoded newlines in query strings #3007

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

Closed
kainosnoema opened this issue Feb 19, 2014 · 3 comments · Fixed by #3010
Closed

v1.1.1 breaks routing with encoded newlines in query strings #3007

kainosnoema opened this issue Feb 19, 2014 · 3 comments · Fixed by #3010

Comments

@kainosnoema
Copy link

The v1.1.1 release introduced URI decoding of path and query params, meaning encoded newlines in query strings (?param=foo%0Abar) prevent matching against ANY route since the regular expression dot (.*) doesn't match newlines. This broke things pretty badly for us, which is frustrating for a point-release.

Not sure what the best fix is, but I'm thinking Router#_routeToRegExp should probably be updated to match against newlines as well. That or there should at least be documentation explaining that query params cannot contain encoded newline characters. Thoughts? I'd be happy to attach a PR to this if there's consensus on how this should be resolved.

@braddunbar
Copy link
Collaborator

Hi @kainosnoema! Fixed this in #3010. Apologies for the breakage and thanks for reporting this!

You're not alone concerning the point release. Take a look at #2888 if you're interested.

@kainosnoema
Copy link
Author

@braddunbar thanks for the quick turnaround on this. The new query string handling is nice, can't wait for another version bump so we can try it out. 👍

@russplaysguitar
Copy link

I think I encountered something related to this in IE 11. Workaround:

    // Not sure why, but IE is unable to match routes with `\n` characters in them?
    // Re-encoding the characters fixes it.    
    Backbone.History.prototype.decodeFragment = _.wrap(Backbone.History.prototype.decodeFragment, function (decodeFragment, fragment) {  
        var decoded = decodeFragment.call(this, fragment);  
        return decoded.replace(/\n/g, '%0A');  
    });

Thought I'd share in case anyone else has this issue. I assume it's just an edge-case that will hopefully get fixed in later releases on IE (maybe Edge?).

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

Successfully merging a pull request may close this issue.

4 participants