Browse Source

Fix #3058 querystring: Fix incorrect handling of empty keys

v0.9.1-release
isaacs 13 years ago
parent
commit
a811a4a130
  1. 5
      lib/querystring.js
  2. 4
      test/simple/test-querystring.js

5
lib/querystring.js

@ -189,6 +189,11 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) {
kstr = x.substring(0, idx),
vstr = x.substring(idx + 1), k, v;
if (kstr === '' && vstr !== '') {
kstr = vstr;
vstr = '';
}
try {
k = decodeURIComponent(kstr);
v = decodeURIComponent(vstr);

4
test/simple/test-querystring.js

@ -55,7 +55,9 @@ var qsTestCases = [
{ hasOwnProperty: 'x',
toString: 'foo',
valueOf: 'bar',
__defineGetter__: 'baz' }]
__defineGetter__: 'baz' }],
// See: https://github.com/joyent/node/issues/3058
['foo&bar=baz', 'foo=&bar=baz', { foo: '', bar: 'baz' }]
];
// [ wonkyQS, canonicalQS, obj ]

Loading…
Cancel
Save