Comparing version 1.2.0 to 1.3.0
@@ -109,5 +109,7 @@ /*global unescape*/ | ||
// We want to percent-encode all everything that'd require a fragment to be enclosed in double quotes: | ||
var unsafeParameterValueRegExp = /[\u0000-\u001f '%\u0080-\uffff]/; | ||
// Allowed in output: <any (US-ASCII) CHAR except SPACE, CTLs (\u0000-\u001f\u007f), "*", "'", "%", or tspecials> | ||
var unsafeParameterValueRegExp = /[\u0000-\u001f \u007f*'%\u0080-\uffff]/; | ||
function quoteParameterIfNecessary(value) { | ||
// tspecials, see definition in rfc2045 | ||
if (/[()<>@,;:\\"\/[\]?=]/.test(value)) { | ||
@@ -133,3 +135,7 @@ return '"' + value.replace(/[\\"]/g, '\\$&') + '"'; | ||
var charCode = value.charCodeAt(i); | ||
encodedValue += '%' + (charCode < 16 ? '0' : '') + charCode.toString(16).toUpperCase(); | ||
if (unsafeParameterValueRegExp.test(value[i])) { | ||
encodedValue += '%' + (charCode < 16 ? '0' : '') + charCode.toString(16).toUpperCase(); | ||
} else { | ||
encodedValue += value[i]; | ||
} | ||
} | ||
@@ -136,0 +142,0 @@ } else { |
{ | ||
"name": "rfc2231", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Encode and decode rfc2231/rfc5987", | ||
@@ -38,3 +38,3 @@ "main": "lib/rfc2231.js", | ||
"coveralls": "2.11.2", | ||
"iconv": "2.1.4", | ||
"iconv": "2.2.1", | ||
"istanbul": "0.3.5", | ||
@@ -41,0 +41,0 @@ "jshint": "2.5.11", |
@@ -115,3 +115,3 @@ /*global describe, it*/ | ||
}, 'to encode back and forth to', { | ||
'bar*': "iso-8859-1''%46%6F%6F%E6" | ||
'bar*': "iso-8859-1''Foo%E6" | ||
}); | ||
@@ -137,2 +137,10 @@ }); | ||
}); | ||
it('parameter value containing delete character', function () { | ||
expect({ | ||
filename: 'abc\x7Fdef.jpg' | ||
}, 'to encode to', { | ||
'filename*': 'iso-8859-1\'\'abc%7Fdef.jpg' | ||
}); | ||
}); | ||
}); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
21000
292
1