Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($location): always decode special chars in $location.url(value) #16354

Merged
merged 1 commit into from
Dec 11, 2017

Conversation

petebacondarwin
Copy link
Contributor

See #16312 (comment)

@bourey - can you check that with this regression fix your original issue is still resolved?

@Narretz
Copy link
Contributor

Narretz commented Dec 1, 2017

I have to admit that I don't really understand what we are trying to fix here. I think a bit more info in the commit message would be useful. 😅

@petebacondarwin
Copy link
Contributor Author

I have updated the commit message @Narretz

@Narretz
Copy link
Contributor

Narretz commented Dec 1, 2017

Thanks! That should help in the future. There were a few typos, here's a cleaned up version:

The original fix for #16312 included changing how $location.url(value)
decoded the special characters passed to it as a setter.
This broke a number of use cases (mostly involving the ui-router).
Further analysis appears to show that we can solve #16312, to prevent
urls being rewritten with decoded values, without modifying the
behaviour of $location.url.
This commit reverts changes to $location.url(value) so that encoded
chars will be decoded and passed to $location.path(value).
In particular it will convert encoded forward slashes, which changes how
the path is updated, since e.g. a/b/%2Fc%2Fd will become a/b/c/d.
While this is arguably not "correct", it appears that there are too many
use cases relying upon this behaviour.

@petebacondarwin
Copy link
Contributor Author

Thanks updated again. Still looking for confirmation from @bourey

@christopherthielen
Copy link

christopherthielen commented Dec 3, 2017

FWIW, the ui-router test suite fails with this build. I'll look into what's breaking.

edit: the test suite is failing due to an unrelated change

@Narretz Narretz changed the title fix($location): fix($location): always decode special chars in $location.url(value) Dec 4, 2017
@petebacondarwin
Copy link
Contributor Author

I am going to land this in 1.6.x and then see if @bourey comes back with a further issue.

The original fix for angular#16312 included changing how `$location.url(value)`
decoded the special characters passed to it as a setter.
This broke a number of use cases (mostly involving the ui-router).

Further analysis appears to show that we can solve angular#16312, to prevent
urls being rewritten with decoded values, without modifying the
behaviour of `$location.url`.

This commit reverts changes to `$location.url(value)` so that encoded
chars will once again be decoded and passed to `$location.path(value)`.
In particular it will convert encoded forward slashes, which changes how
the path is updated, since e.g. `a/b/%2Fc%2Fd` will become `a/b/c/d`.
While this is arguably not "correct", it appears that there are too many
use cases relying upon this behaviour.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants