From ac4791393edd56e46a54b93ed8349eef7b7e1801 Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 11 Aug 2011 15:30:56 -0700 Subject: [PATCH] Fix #1497 querystring: Replace 'in' test with 'hasOwnProperty' --- lib/querystring.js | 2 +- test/simple/test-querystring.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/querystring.js b/lib/querystring.js index aa433982a6..0effe5b167 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -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]; diff --git a/test/simple/test-querystring.js b/test/simple/test-querystring.js index 8e30dae1e5..18d06422a1 100644 --- a/test/simple/test-querystring.js +++ b/test/simple/test-querystring.js @@ -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 ]