From cd470d48e8f0fa31e343af58983dc0694209c282 Mon Sep 17 00:00:00 2001 From: Modest Machnicki Date: Wed, 10 Feb 2016 15:30:49 +0100 Subject: [PATCH] decodeURIComponent - prevent URIError Replace decodeURIComponent with tryDecodeURIComponent to prevent throwing "URIError: malformed URI sequence". https://github.com/angular/angular.js/blob/master/src/Angular.js#L1275 --- src/ng/location.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ng/location.js b/src/ng/location.js index 3c91549b53b4..5de15bb846e5 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -37,10 +37,10 @@ function parseAppUrl(relativeUrl, locationObj) { relativeUrl = '/' + relativeUrl; } var match = urlResolve(relativeUrl); - locationObj.$$path = decodeURIComponent(prefixed && match.pathname.charAt(0) === '/' ? + locationObj.$$path = tryDecodeURIComponent(prefixed && match.pathname.charAt(0) === '/' ? match.pathname.substring(1) : match.pathname); locationObj.$$search = parseKeyValue(match.search); - locationObj.$$hash = decodeURIComponent(match.hash); + locationObj.$$hash = tryDecodeURIComponent(match.hash); // make sure path starts with '/'; if (locationObj.$$path && locationObj.$$path.charAt(0) != '/') { @@ -385,7 +385,7 @@ var locationPrototype = { } var match = PATH_MATCH.exec(url); - if (match[1] || url === '') this.path(decodeURIComponent(match[1])); + if (match[1] || url === '') this.path(tryDecodeURIComponent(match[1])); if (match[2] || match[1] || url === '') this.search(match[3] || ''); this.hash(match[5] || '');