libmime 2.1.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/lib/libmime.js +20 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v3.0.0 2016-12-08
|
|
4
|
+
|
|
5
|
+
* Updated encoded-word generation. Previously a minimal value was encoded, so it was possible to have multiple encoded words in a string separated by non encoded-words. This was an issue with some webmail clients that stripped out the non-encoded parts between encoded-words so the updated method uses wide match by encoding from the first word with unicode characters to the last word. "a =?b?= c =?d?= e" -> "a =?bcd?= e"
|
|
6
|
+
|
|
3
7
|
## v2.1.3 2016-12-08
|
|
4
8
|
|
|
5
9
|
* Revert dot as a special symbol
|
package/lib/libmime.js
CHANGED
|
@@ -220,12 +220,27 @@ var libmime = module.exports = {
|
|
|
220
220
|
|
|
221
221
|
maxLength = maxLength || 0;
|
|
222
222
|
|
|
223
|
-
var decodedValue = libcharset.decode(libcharset.convert((data || ''), fromCharset))
|
|
224
|
-
|
|
223
|
+
var decodedValue = libcharset.decode(libcharset.convert((data || ''), fromCharset));
|
|
224
|
+
var encodedValue;
|
|
225
225
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
var firstMatch = decodedValue.match(/(?:^|\s)([^\s]*[\u0080-\uFFFF])/);
|
|
227
|
+
if (!firstMatch) {
|
|
228
|
+
return decodedValue;
|
|
229
|
+
}
|
|
230
|
+
var lastMatch = decodedValue.match(/([\u0080-\uFFFF][^\s]*)[^\u0080-\uFFFF]*$/);
|
|
231
|
+
if (!lastMatch) {
|
|
232
|
+
// should not happen
|
|
233
|
+
return decodedValue;
|
|
234
|
+
}
|
|
235
|
+
var startIndex = firstMatch.index + (firstMatch[0].match(/[^\s]/) || {
|
|
236
|
+
index: 0
|
|
237
|
+
}).index;
|
|
238
|
+
var endIndex = lastMatch.index + (lastMatch[1] || '').length;
|
|
239
|
+
|
|
240
|
+
encodedValue =
|
|
241
|
+
(startIndex ? decodedValue.substr(0, startIndex) : '') +
|
|
242
|
+
libmime.encodeWord(decodedValue.substring(startIndex, endIndex), mimeWordEncoding || 'Q', maxLength) +
|
|
243
|
+
(endIndex < decodedValue.length ? decodedValue.substr(endIndex) : '');
|
|
229
244
|
|
|
230
245
|
return encodedValue;
|
|
231
246
|
},
|