fix($location): prevent infinite digest with IDN urls in Edge
Internationalized Domain Urls, for example urls with Umlaut (Ä, Ö, Ü) cause infinite digest in Edge 38.14393.0.0 because lastIndexOf doesn't work correctly in this version when the search string is the same as the haystack string. The patch uses an implementation based on core.js: https://github.com/zloirock/core-js/blob/v2.4.1/modules/es6.string.starts-with.js#L16 Edge Bug: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/9271625/ Fixes #15217 PR #15235
This commit is contained in:
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user