Skip to content

Commit

Permalink
Use encodeUriQuery/decodeURIComponent instead of escape/unescape in {…
Browse files Browse the repository at this point in the history
…to,from}KeyValue

This is bug angular#492, but I can't wait for the $location service rewrite.
  • Loading branch information
groner committed Sep 5, 2011
1 parent 05ad1ce commit 0a246e8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,8 @@ function parseKeyValue(/**string*/keyValue) {
forEach((keyValue || "").split('&'), function(keyValue){
if (keyValue) {
key_value = keyValue.split('=');
key = unescape(key_value[0]);
obj[key] = isDefined(key_value[1]) ? unescape(key_value[1]) : true;
key = decodeURIComponent(key_value[0]);
obj[key] = isDefined(key_value[1]) ? decodeURIComponent(key_value[1]) : true;
}
});
return obj;
Expand All @@ -867,7 +867,7 @@ function parseKeyValue(/**string*/keyValue) {
function toKeyValue(obj) {
var parts = [];
forEach(obj, function(value, key) {
parts.push(escape(key) + (value === true ? '' : '=' + escape(value)));
parts.push(encodeUriQuery(key, true) + (value === true ? '' : '=' + encodeUriQuery(value, true)));
});
return parts.length ? parts.join('&') : '';
}
Expand Down

0 comments on commit 0a246e8

Please sign in to comment.