projects
/
platform
/
upstream
/
nodejs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
12fc9fa
)
Fix #3058 querystring: Fix incorrect handling of empty keys
author
isaacs
<i@izs.me>
Fri, 11 May 2012 15:49:03 +0000
(08:49 -0700)
committer
isaacs
<i@izs.me>
Fri, 11 May 2012 15:49:03 +0000
(08:49 -0700)
lib/querystring.js
patch
|
blob
|
history
test/simple/test-querystring.js
patch
|
blob
|
history
diff --git
a/lib/querystring.js
b/lib/querystring.js
index
7aa6e84
..
3c03cf3
100644
(file)
--- a/
lib/querystring.js
+++ b/
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);
diff --git
a/test/simple/test-querystring.js
b/test/simple/test-querystring.js
index
0764481
..
2d86625
100644
(file)
--- a/
test/simple/test-querystring.js
+++ b/
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 ]