diff --git a/lib/querystring.js b/lib/querystring.js index 6aca65dee5b..c6dc1afcf5f 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -555,8 +555,9 @@ function parse(qs, sep, eq, options) { key += StringPrototypeSlice(qs, lastPos, i); key += plusChar; lastPos = i + 1; - continue; } + // Don't let key characters affect value encoding. + continue; } if (code === 43/* + */) { if (lastPos < i) diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js index b24ec5b569b..ec463e4a45b 100644 --- a/test/parallel/test-querystring.js +++ b/test/parallel/test-querystring.js @@ -415,6 +415,18 @@ assert.strictEqual(qs.unescapeBuffer('a%%').toString(), 'a%%'); // Test invalid encoded string check(qs.parse('%\u0100=%\u0101'), { '%Ā': '%ā' }); +// Test encoded key with unencoded value +{ + const input = '%C3%A4=caf\u00e9%'; + + check( + qs.parse(input), + { '\u00e4': 'caf\u00e9%' }); + check( + qs.parse(input, null, null), + { '\u00e4': 'caf\u00e9%' }); +} + // Test custom decode { function demoDecode(str) {