Permalink
Browse files

Fixed handling of parameters with names that are keys in Object.proto…

…type.
  • Loading branch information...
1 parent 6014c13 commit ec28f81409f9c58bcbc92acb57ba7a8a3824a7fa @MaxNanasy committed May 25, 2012
Showing with 3 additions and 2 deletions.
  1. +1 −1 querystring.js
  2. +2 −1 test-querystring.js
View
@@ -145,7 +145,7 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq) {
var k = QueryString.unescape(x[0], true);
var v = QueryString.unescape(x.slice(1).join(eq), true);
- if (!(k in obj)) {
+ if (!(obj.hasOwnProperty(k))) {
obj[k] = v;
} else if (!Array.isArray(obj[k])) {
obj[k] = [obj[k], v];
View
@@ -26,7 +26,8 @@ var qsTestCases = [
'undef': ''}],
[' foo = bar ', '%20foo%20=%20bar%20', {' foo ': ' bar '}],
['foo=%zx', 'foo=%25zx', {'foo': '%zx'}],
- ['foo=%EF%BF%BD', 'foo=%EF%BF%BD', {'foo': '\ufffd' }]
+ ['foo=%EF%BF%BD', 'foo=%EF%BF%BD', {'foo': '\ufffd' }],
+ ['toString=bar', 'toString=bar', {'toString': 'bar'}]
];
// [ wonkyQS, canonicalQS, obj ]

0 comments on commit ec28f81

Please sign in to comment.