This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Location path 2 #15365
Merged
petebacondarwin
merged 2 commits into
angular:master
from
petebacondarwin:location-path-2
Nov 9, 2016
Merged
Location path 2 #15365
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@ngdoc error | ||
@name $location:badpath | ||
@fullName Invalid Path | ||
@description | ||
|
||
This error occurs when the path of a location contains invalid characters. | ||
The most common fault is when the path starts with double slashes (`//`) or backslashes ('\\'). | ||
For example if the base path of an application is `https://a.b.c/` then the following path is | ||
invalid `https://a.b.c///d/e/f`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -389,7 +389,7 @@ describe('$location', function() { | |
|
||
|
||
it('should throw error when invalid server url given', function() { | ||
var locationUrl = new LocationHtml5Url('http://server.org/base/abc', 'http://server.org/base/', '/base'); | ||
var locationUrl = new LocationHtml5Url('http://server.org/base/abc', 'http://server.org/base/'); | ||
|
||
expect(function() { | ||
locationUrl.$$parse('http://other.server.org/path#/path'); | ||
|
@@ -398,7 +398,7 @@ describe('$location', function() { | |
|
||
|
||
it('should throw error when invalid base url given', function() { | ||
var locationUrl = new LocationHtml5Url('http://server.org/base/abc', 'http://server.org/base/', '/base'); | ||
var locationUrl = new LocationHtml5Url('http://server.org/base/abc', 'http://server.org/base/'); | ||
|
||
expect(function() { | ||
locationUrl.$$parse('http://server.org/path#/path'); | ||
|
@@ -2453,9 +2453,9 @@ describe('$location', function() { | |
var locationUrl, locationUmlautUrl, locationIndexUrl; | ||
|
||
beforeEach(function() { | ||
locationUrl = new LocationHtml5Url('http://server/pre/', 'http://server/pre/', 'http://server/pre/path'); | ||
locationUmlautUrl = new LocationHtml5Url('http://särver/pre/', 'http://särver/pre/', 'http://särver/pre/path'); | ||
locationIndexUrl = new LocationHtml5Url('http://server/pre/index.html', 'http://server/pre/', 'http://server/pre/path'); | ||
locationUrl = new LocationHtml5Url('http://server/pre/', 'http://server/pre/'); | ||
locationUmlautUrl = new LocationHtml5Url('http://särver/pre/', 'http://särver/pre/'); | ||
locationIndexUrl = new LocationHtml5Url('http://server/pre/index.html', 'http://server/pre/'); | ||
}); | ||
|
||
it('should rewrite URL', function() { | ||
|
@@ -2480,6 +2480,19 @@ describe('$location', function() { | |
expect(parseLinkAndReturn(locationUrl, 'someIgnoredAbsoluteHref', '#test')).toEqual('http://server/pre/otherPath#test'); | ||
}); | ||
|
||
it('should complain if the path starts with double slashes', function() { | ||
expect(function() { | ||
parseLinkAndReturn(locationUrl, 'http://server/pre///other/path'); | ||
}).toThrowMinErr('$location', 'badpath'); | ||
|
||
expect(function() { | ||
parseLinkAndReturn(locationUrl, 'http://server/pre/\\\\other/path'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a test case with mixed slashes ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will do |
||
}).toThrowMinErr('$location', 'badpath'); | ||
|
||
expect(function() { | ||
parseLinkAndReturn(locationUrl, 'http://server/pre//\\//other/path'); | ||
}).toThrowMinErr('$location', 'badpath'); | ||
}); | ||
|
||
it('should complain if no base tag present', function() { | ||
module(function($locationProvider) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?