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

fix($location): prevent infinite digest with IDN urls in Edge #15235

Merged
merged 2 commits into from
Oct 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ function parseAppUrl(relativeUrl, locationObj) {
}
}

function startsWith(haystack, needle) {
return haystack.lastIndexOf(needle, 0) === 0;
function startsWith(str, search) {
return str.slice(0, search.length) === search;
}

/**
Expand Down
10 changes: 9 additions & 1 deletion test/ng/locationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2450,10 +2450,11 @@ describe('$location', function() {


describe('LocationHtml5Url', function() {
var locationUrl, locationIndexUrl;
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');
});

Expand All @@ -2465,6 +2466,13 @@ describe('$location', function() {
// Note: relies on the previous state!
expect(parseLinkAndReturn(locationUrl, 'someIgnoredAbsoluteHref', '#test')).toEqual('http://server/pre/otherPath#test');

expect(parseLinkAndReturn(locationUmlautUrl, 'http://other')).toEqual(undefined);
expect(parseLinkAndReturn(locationUmlautUrl, 'http://särver/pre')).toEqual('http://särver/pre/');
expect(parseLinkAndReturn(locationUmlautUrl, 'http://särver/pre/')).toEqual('http://särver/pre/');
expect(parseLinkAndReturn(locationUmlautUrl, 'http://särver/pre/otherPath')).toEqual('http://särver/pre/otherPath');
// Note: relies on the previous state!
expect(parseLinkAndReturn(locationUmlautUrl, 'someIgnoredAbsoluteHref', '#test')).toEqual('http://särver/pre/otherPath#test');

expect(parseLinkAndReturn(locationIndexUrl, 'http://server/pre')).toEqual('http://server/pre/');
expect(parseLinkAndReturn(locationIndexUrl, 'http://server/pre/')).toEqual('http://server/pre/');
expect(parseLinkAndReturn(locationIndexUrl, 'http://server/pre/otherPath')).toEqual('http://server/pre/otherPath');
Expand Down