Skip to content

Commit

Permalink
Fix nodejs#1497 querystring: Replace 'in' test with 'hasOwnProperty'
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Aug 11, 2011
1 parent d1a2628 commit 3210809
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,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];
Expand Down
7 changes: 6 additions & 1 deletion test/simple/test-querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ 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=foo&valueOf=bar&__defineGetter__=baz',
'toString=foo&valueOf=bar&__defineGetter__=baz',
{ toString: 'foo',
valueOf: 'bar',
__defineGetter__: 'baz' } ]
];

// [ wonkyQS, canonicalQS, obj ]
Expand Down

0 comments on commit 3210809

Please sign in to comment.