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

fix(angular.encodeUriSegment): do not encode semi-colon #5019

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/ng/location.js
Expand Up @@ -37,15 +37,17 @@ function parseAppUrl(relativeUrl, locationObj, appBase) {
relativeUrl = '/' + relativeUrl;
}
var match = urlResolve(relativeUrl, appBase);
locationObj.$$path = decodeURIComponent(prefixed && match.pathname.charAt(0) === '/' ?
match.pathname.substring(1) : match.pathname);
locationObj.$$search = parseKeyValue(match.search);
locationObj.$$hash = decodeURIComponent(match.hash);
locationObj.pathEncoded = prefixed && match.pathname.charAt(0) === '/' ?
match.pathname.substring(1) : match.pathname;

// make sure path starts with '/';
if (locationObj.$$path && locationObj.$$path.charAt(0) != '/') {
locationObj.$$path = '/' + locationObj.$$path;
if (locationObj.pathEncoded && locationObj.pathEncoded.charAt(0) != '/') {
locationObj.pathEncoded = '/' + locationObj.pathEncoded;
}

locationObj.$$path = decodeURIComponent(locationObj.pathEncoded);
locationObj.$$search = parseKeyValue(match.search);
locationObj.$$hash = decodeURIComponent(match.hash);
}


Expand Down Expand Up @@ -123,7 +125,7 @@ function LocationHtml5Url(appBase, basePrefix) {
var search = toKeyValue(this.$$search),
hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';

this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
this.$$url = this.pathEncoded + (search ? '?' + search : '') + hash;
this.$$absUrl = appBaseNoFile + this.$$url.substr(1); // first char is always '/'
};

Expand Down Expand Up @@ -190,7 +192,7 @@ function LocationHashbangUrl(appBase, hashPrefix) {
var search = toKeyValue(this.$$search),
hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';

this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
this.$$url = this.pathEncoded + (search ? '?' + search : '') + hash;
this.$$absUrl = appBase + (this.$$url ? hashPrefix + this.$$url : '');
};

Expand Down Expand Up @@ -350,8 +352,10 @@ LocationHashbangInHtml5Url.prototype =
* @param {string=} path New path
* @return {string} path
*/
path: locationGetterSetter('$$path', function(path) {
return path.charAt(0) == '/' ? path : '/' + path;
path: locationGetterSetter('$$path', function(path, locationObj) {
path = path.charAt(0) == '/' ? path : '/' + path;
locationObj.pathEncoded = encodePath(path);
return path;
}),

/**
Expand Down Expand Up @@ -446,7 +450,7 @@ function locationGetterSetter(property, preprocess) {
if (isUndefined(value))
return this[property];

this[property] = preprocess(value);
this[property] = preprocess(value, this);
this.$$compose();

return this;
Expand Down