0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

Fix #1497 querystring: Replace 'in' test with 'hasOwnProperty'

This commit is contained in:
isaacs 2011-08-11 15:30:56 -07:00
parent eb09b0644b
commit ac4791393e
2 changed files with 7 additions and 2 deletions

View File

@ -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];

View File

@ -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 ]