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

Location path 2 #15365

Merged
merged 2 commits into from
Nov 9, 2016
Merged

Conversation

petebacondarwin
Copy link
Contributor

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

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

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

Does this PR introduce a breaking change?
The previous behaviour would have led to a broken app, so it is highly
unlikely that any app relied on this behaviour. So this doesn't constitute
a breaking change.

Please check if the PR fulfills these requirements

Other information:

Alternative solution #15359

if (isDefined(appUrl = stripBaseUrl(appBase, url))) {
prevAppUrl = appUrl;
if (isDefined(appUrl = stripBaseUrl(basePrefix, appUrl))) {
if (basePrefix && isDefined(appUrl = stripBaseUrl(basePrefix, appUrl))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

interestingly I think this was actually the cause of the bug in the first place...

Copy link
Member

Choose a reason for hiding this comment

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

There are no tests for this change, are there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No new tests, specifically, but it doesn't break any of the current tests
And there are the new tests with the double slashes.
I couldn't think of a specific test for this change. Any ideas?

}).toThrowMinErr('$location', 'badpath');

expect(function() {
parseLinkAndReturn(locationUrl, 'http://server/pre/\\\\other/path');
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a test case with mixed slashes (pre//\\//other/path) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do


function parseAppUrl(relativeUrl, locationObj) {
var prefixed = (relativeUrl.charAt(0) !== '/');
if (url.search(DOUBLE_SLASH_REGEX) === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

You could also add ^ at the beginning of DOUBLE_SLASH_REGEX and use DOUBLE_SLASH_REGEX.test(url)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true

petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request Nov 5, 2016
Previously `$location` was rewriting such paths to remove not only the
double slashes but also the first segment of the path, leading to an invalid
path.

In this change, we deem leading double (back)slashes an invalid path and
now throw a `$location:badpath` error if that occurs.

Closes angular#15365
@petebacondarwin
Copy link
Contributor Author

@koto and @mprobst - any further comments before we merge this?

@koto
Copy link
Contributor

koto commented Nov 7, 2016

Looks good to me, security-wise.

On Mon, Nov 7, 2016, 12:10 Pete Bacon Darwin [email protected]
wrote:

@koto https://github.com/koto and @mprobst https://github.com/mprobst

  • any further comments before we merge this?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#15365 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAH0q3zX-T7nINjGyNQnmgFsrH2up6INks5q7wc6gaJpZM4KpoUt
.

@mprobst
Copy link
Contributor

mprobst commented Nov 7, 2016

LGTM

Previously `$location` was rewriting such paths to remove not only the
double slashes but also the first segment of the path, leading to an invalid
path.

In this change, we deem leading double (back)slashes an invalid path and
now throw a `$location:badpath` error if that occurs.

Closes angular#15365
@petebacondarwin petebacondarwin merged commit 4aa9534 into angular:master Nov 9, 2016
petebacondarwin added a commit that referenced this pull request Nov 9, 2016
Previously `$location` was rewriting such paths to remove not only the
double slashes but also the first segment of the path, leading to an invalid
path.

In this change, we deem leading double (back)slashes an invalid path and
now throw a `$location:badpath` error if that occurs.

Closes #15365
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
Previously `$location` was rewriting such paths to remove not only the
double slashes but also the first segment of the path, leading to an invalid
path.

In this change, we deem leading double (back)slashes an invalid path and
now throw a `$location:badpath` error if that occurs.

Closes angular#15365
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
Previously `$location` was rewriting such paths to remove not only the
double slashes but also the first segment of the path, leading to an invalid
path.

In this change, we deem leading double (back)slashes an invalid path and
now throw a `$location:badpath` error if that occurs.

Closes angular#15365
@ivanrey
Copy link

ivanrey commented Dec 14, 2016

This fix has problems with internal routing of an app. Sometimes double slash in fragments might be important to indicate an specific state.

I believe this fix should not take into account the fragment part of the URL since it's not sent to the server and breaks some applications.

@gkalpak
Copy link
Member

gkalpak commented Dec 14, 2016

@ivanrey, afaict this is supposed to only check for the beginning of the client-side URL and I think it didn't work correctly before either. Do you have a specific usecase/demo you can share, that used to work before and broke as a result of this fix?

ellimist pushed a commit to ellimist/angular.js that referenced this pull request Mar 15, 2017
Previously `$location` was rewriting such paths to remove not only the
double slashes but also the first segment of the path, leading to an invalid
path.

In this change, we deem leading double (back)slashes an invalid path and
now throw a `$location:badpath` error if that occurs.

Closes angular#15365
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.

7 participants