unescape fallback for malformed uri components #20

Open
wants to merge 3 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+7 −2
Diff settings

Always

Just for now

View
@@ -47,7 +47,7 @@ exports.parse = function(str){
try{
pair = decodeURIComponent(pair.replace(/\+/g, ' '));
} catch(e) {
- // ignore
+ pair = unescape(pair.replace(/\+/g, ' '));
}
var eql = pair.indexOf('=')
View
@@ -140,8 +140,13 @@ module.exports = {
'test malformed uri': function(){
qs.parse('{%:%}').should.eql({ '{%:%}': '' });
qs.parse('foo=%:%}').should.eql({ 'foo': '%:%}' });
+ qs.parse('foo=%:%}%20').should.eql({ 'foo': '%:%} ' });
+ },
+
+ 'test unescaping of non-utf8 encoded data': function(){
+ qs.parse('foo=%E4%20bar').should.eql({ 'foo': String.fromCharCode('228') + ' bar' });
}
-
+
// 'test complex': function(){
// qs.parse('users[][name][first]=tj&users[foo]=bar')
// .should.eql({