Skip to content

URL Path is Decoded Twice, leading to errors or worse if the escape character % is present in the decoded string #278

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
dbkang opened this issue Jul 24, 2013 · 5 comments · Fixed by #279

Comments

@dbkang
Copy link
Contributor

dbkang commented Jul 24, 2013

$location.path() in AngularJS already returns a decoded string (see how $$path is set), but UrlMatcher.prototype.exec, which takes path from $location.path() calls decodeURIComponent again on decoded string, which results in an error or possibly an incorrect string if the decoded string itself contains the escape character.

Also, I don't know if this is compensating for the other bug, but in UrlMatcher.prototype.format, encodeURIComponent is missing for the path part of the URL - should be result += encodeURIComponent(value).

@timkindberg
Copy link
Contributor

@dkang81, would you be interested in submitting a pull request with passing tests? If you had time to fix the issues, we could def use the help! Otherwise we can look into it when we get a chance.

@nateabele
Copy link
Contributor

@dkang81 Or, if you could just submit a patch with a failing test that demonstrates the issue, I can patch it. Thanks.

@dbkang
Copy link
Contributor Author

dbkang commented Jul 25, 2013

@timkindberg @nateabele wow, thanks for quick responses guys, I do have unit tests and a fix for this now, just need to ask my boss for permission, should be able to submit a pull request sometime tomorrow!

@nateabele
Copy link
Contributor

Awesome, thanks man.

@ksperling
Copy link
Contributor

I think the fix is good as it stands now, however something to think about is if urlMatcher shouldn't really be looking at non-decoded URLs (and we should have some way to get that from $location).

If I have a state 'test' with a URL pattern like '/foo/:whatever/bar', it should round-trip correctly even if I transitionTo('test', { whatever: 'evil/slash' }).

Or am I missing something?

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 a pull request may close this issue.

4 participants