Comparing version 0.1.6 to 0.1.7
# Changelog | ||
## v0.1.7 2015-01-19 | ||
Updated unicode filename handling – only revert to parameter continuation if the value actually includes | ||
non-ascii characters or is too long. Previously filenames were encoded if they included anything | ||
besides letters, numbers, dot or space. | ||
## v0.1.6 2014-10-25 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "libmime", | ||
"description": "Encode and decode quoted printable and base64 strings", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"main": "src/libmime", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/andris9/libmime", |
@@ -192,4 +192,4 @@ # libmime | ||
``` | ||
Content-disposition: attachment; filename*0*="utf-8''filename%20" | ||
filename*1*="%C3%B5%C3%A4%C3%B6"; filename*2*="%C3%BC.txt" | ||
Content-disposition: attachment; filename*0*=utf-8''filename%20 | ||
filename*1*=%C3%B5%C3%A4%C3%B6; filename*2*=%C3%BC.txt | ||
``` | ||
@@ -196,0 +196,0 @@ |
@@ -51,19 +51,19 @@ 'use strict'; | ||
split(/\r?\n/). | ||
// remove soft linebreaks | ||
// soft linebreaks are added after space symbols | ||
// remove soft linebreaks | ||
// soft linebreaks are added after space symbols | ||
reduce(function(previousValue, currentValue, index) { | ||
var body = previousValue; | ||
if (delSp) { | ||
// delsp adds spaces to text to be able to fold it | ||
// these spaces can be removed once the text is unfolded | ||
body = body.replace(/[ ]+$/, ''); | ||
} | ||
if (/ $/.test(previousValue) && !/(^|\n)\-\- $/.test(previousValue) || index === 1) { | ||
return body + currentValue; | ||
} else { | ||
return body + '\n' + currentValue; | ||
} | ||
}). | ||
// remove whitespace stuffing | ||
// http://tools.ietf.org/html/rfc3676#section-4.4 | ||
var body = previousValue; | ||
if (delSp) { | ||
// delsp adds spaces to text to be able to fold it | ||
// these spaces can be removed once the text is unfolded | ||
body = body.replace(/[ ]+$/, ''); | ||
} | ||
if (/ $/.test(previousValue) && !/(^|\n)\-\- $/.test(previousValue) || index === 1) { | ||
return body + currentValue; | ||
} else { | ||
return body + '\n' + currentValue; | ||
} | ||
}). | ||
// remove whitespace stuffing | ||
// http://tools.ietf.org/html/rfc3676#section-4.4 | ||
replace(/^ /gm, ''); | ||
@@ -288,3 +288,3 @@ }, | ||
var value = structured.params[param]; | ||
if (param === 'filename' || !libmime.isPlainText(value) || value.length >= 75) { | ||
if (!libmime.isPlainText(value) || value.length >= 75) { | ||
libmime.buildHeaderParam(param, value, 50).forEach(function(encodedParam) { | ||
@@ -294,3 +294,3 @@ if (!/[\s"\\;\/=]|^[\-']|'$/.test(encodedParam.value)) { | ||
} else { | ||
paramsArray.push(encodedParam.key + '="' + encodedParam.value + '"'); | ||
paramsArray.push(encodedParam.key + '=' + JSON.stringify(encodedParam.value)); | ||
} | ||
@@ -300,3 +300,3 @@ }); | ||
if (/[\s'"\\;\/=]|^\-/.test(value)) { | ||
paramsArray.push(param + '="' + value.replace(/(["\\])/g, "\\$1") + '"'); | ||
paramsArray.push(param + '=' + JSON.stringify(value)); | ||
} else { | ||
@@ -429,12 +429,12 @@ paramsArray.push(param + '=' + value); | ||
value. | ||
// fix invalidly encoded chars | ||
// fix invalidly encoded chars | ||
replace(/[=\?_\s]/g, function(s) { | ||
var c = s.charCodeAt(0).toString(16); | ||
if (s === ' ') { | ||
return '_'; | ||
} else { | ||
return '%' + (c.length < 2 ? '0' : '') + c; | ||
} | ||
}). | ||
// change from urlencoding to percent encoding | ||
var c = s.charCodeAt(0).toString(16); | ||
if (s === ' ') { | ||
return '_'; | ||
} else { | ||
return '%' + (c.length < 2 ? '0' : '') + c; | ||
} | ||
}). | ||
// change from urlencoding to percent encoding | ||
replace(/%/g, '=') + | ||
@@ -458,4 +458,4 @@ '?='; | ||
* becomes | ||
* title*0*="utf-8''unicode" | ||
* title*1*="%20string" | ||
* title*0*=utf-8''unicode | ||
* title*1*=%20string | ||
* | ||
@@ -478,3 +478,3 @@ * @param {String|Buffer} data String to be encoded | ||
// process ascii only text | ||
if (/^[\w.\- ]*$/.test(data)) { | ||
if (libmime.isPlainText(data)) { | ||
@@ -481,0 +481,0 @@ // check if conversion is even needed |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129668