Skip to content

Fixed handling of parameters with names that are keys in Object.prototype. #1

Open
wants to merge 3 commits into from
View
2 querystring.js 100644 → 100755
@@ -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 (!(Object.prototype.hasOwnProperty.call(obj, k))) {
obj[k] = v;
} else if (!Array.isArray(obj[k])) {
obj[k] = [obj[k], v];
View
6 test-querystring.js 100644 → 100755
@@ -26,7 +26,11 @@ 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'}],
+ ['hasOwnProperty=bar&hasOwnProperty=quux',
+ 'hasOwnProperty=bar&hasOwnProperty=quux',
+ {'hasOwnProperty': ['bar', 'quux']}]
];
// [ wonkyQS, canonicalQS, obj ]
Something went wrong with that request. Please try again.