diff options
author | Tristan Berger <tristan.berger@gmail.com> | 2014-08-26 04:39:25 -0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-08-27 13:49:16 +0400 |
commit | 0f2956192c51abc6fc8311102b004f1e975e157f (patch) | |
tree | 1370c2bafcf956f1b14e232d0a0e926f8bd48a6a /test | |
parent | f39e608c6eb11c91839ea4661caece1f89f1b12f (diff) | |
download | android-node-v8-0f2956192c51abc6fc8311102b004f1e975e157f.tar.gz android-node-v8-0f2956192c51abc6fc8311102b004f1e975e157f.tar.bz2 android-node-v8-0f2956192c51abc6fc8311102b004f1e975e157f.zip |
querystring: fix unescape override
Documentation states that `querystring.unescape` may be overridden to
replace unescaper during parsing. However, the function was only
being used as a fallback for when the native decoder throws (on a
malformed URL). This patch moves the call to the native function and
the try/catch around it into querystring.unescape then has the parser
always invoke it, so that an override will always be used.
Fixes #4055
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/simple/test-querystring.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/simple/test-querystring.js b/test/simple/test-querystring.js index 2d86625f32..545c507fc4 100644 --- a/test/simple/test-querystring.js +++ b/test/simple/test-querystring.js @@ -229,3 +229,11 @@ assert.equal(0xeb, b[16]); assert.equal(0xd8, b[17]); assert.equal(0xa2, b[18]); assert.equal(0xe6, b[19]); + +// test overriding .unescape +var prevUnescape = qs.unescape; +qs.unescape = function (str) { + return str.replace(/o/g, '_'); +}; +assert.deepEqual(qs.parse('foo=bor'), {f__: 'b_r'}); +qs.unescape = prevUnescape; |