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

Commit

Permalink
fix(angular.encodeUriSegment): do not encode semi-colon
Browse files Browse the repository at this point in the history
RFC 3986 indicates that ; is not encoded as part of the URI, as is the case
with other members of sub-delim. Changed encodeUriSegment to match that
behaviour, along with the corresponding spec.
  • Loading branch information
brettporter committed Nov 19, 2013
1 parent 751f058 commit 0ea270e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Angular.js
Expand Up @@ -1065,6 +1065,7 @@ function toKeyValue(obj) {
*/
function encodeUriSegment(val) {
return encodeUriQuery(val, true).
replace(/%3B/gi, ';').
replace(/%26/gi, '&').
replace(/%3D/gi, '=').
replace(/%2B/gi, '+');
Expand Down
10 changes: 5 additions & 5 deletions test/AngularSpec.js
Expand Up @@ -569,12 +569,12 @@ describe('angular', function() {
toEqual("-_.!~*'()%20-_.!~*'()");

//don't encode the rest of pchar'
expect(encodeUriSegment(':@&=+$, :@&=+$,')).
toEqual(':@&=+$,%20:@&=+$,');
expect(encodeUriSegment(':;@&=+$, :;@&=+$,')).
toEqual(':;@&=+$,%20:;@&=+$,');

//encode '/', ';' and ' ''
expect(encodeUriSegment('/; /;')).
toEqual('%2F%3B%20%2F%3B');
//encode '/', and ' ''
expect(encodeUriSegment('/ /')).
toEqual('%2F%20%2F');
});
});

Expand Down

0 comments on commit 0ea270e

Please sign in to comment.