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

fix($location): do not decode forward slashes in the path in HTML5 mode #16316

Merged

Conversation

petebacondarwin
Copy link
Member

Closes #16312

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

bug fix

What is the current behavior? (You can also link to an open issue here)

See #16312

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change?

It depends what people expected of the location escaping...
I think what we had before was buggy. So no.

Please check if the PR fulfills these requirements

Other information:

@petebacondarwin
Copy link
Member Author

Be aware that this does not change the behaviour of hash-bang (non-HTML5 mode) paths. This is because slashes do not need to be escaped once they are in the hash section of the URI and we have tests that expect encoded slashes to be decoded into the path when parsed by $location. Thus changing that behaviour would most likely constitute a breaking change.

The use case in #16312 is very unlikely to use hashbang mode since it is a hybrid AngularJS/Angular app that would run on browsers that support HTML5 mode.

Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am very sure someone's app just broke 😃


function decodePath(path, html5Mode) {
var segments = path.split('/'),
i = segments.length;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No indentation? 😞

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱

@petebacondarwin petebacondarwin merged commit 0cbc505 into angular:master Nov 3, 2017
@petebacondarwin petebacondarwin deleted the issue-16312-matrix-params branch November 3, 2017 11:07
@veloek
Copy link

veloek commented Nov 28, 2017

@gkalpak You're so right! The change from decodeURIComponent to decodeURI on line 425 broke our URL matcher type in ui-router since decodeURI doesn't decode %2F to / in the path (we don't use html5-mode).

I would like to see this one line reverted, but I'm not sure what the implications are...

Please let me know if you need any more info from me.

@frederikprijck
Copy link
Contributor

frederikprijck commented Nov 28, 2017

I would like to see this one line reverted, but I'm not sure what the implications are...

@veloek Fwiw: I guess, for the time being, you can roll back to 1.6.6 and lock your angularjs version.

@veloek
Copy link

veloek commented Nov 28, 2017

@frederikprijck Yup, that's what I did :)

@petebacondarwin
Copy link
Member Author

petebacondarwin commented Nov 28, 2017

@veloek - can you provide a reproduction of the regression for us?
If you are not using html5mode then the behaviour should not have changed for you...

@veloek
Copy link

veloek commented Nov 28, 2017

@petebacondarwin I'll see if I get the time :)

I guess the locationPrototype.url function is used in both html5mode and "hash-mode", right?

@petebacondarwin
Copy link
Member Author

Hmm, I see. We probably need to shift some of that logic into the different implementations: LocationHtml5Url and LocationHashbangUrl.

@petebacondarwin
Copy link
Member Author

Here is a fix for the regression: #16350

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.

AngularJS unescapes matrix parameters
5 participants