8000 decodeURIComponent - prevent URIError by modmac · Pull Request #13993 · angular/angular.js · GitHub
[go: up one dir, main page]

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

decodeURIComponent - prevent URIError #13993

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
  • Loading branch information
modmac committed Feb 10, 2016
commit cd470d48e8f0fa31e343af58983dc0694209c282
6 changes: 3 additions & 3 deletions src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) != '/') {
Expand Down Expand Up @@ -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] || '');

Expand Down
0