libmime 2.0.3 → 2.1.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/.eslintrc.js +2 -1
- package/CHANGELOG.md +4 -0
- package/lib/charset.js +1 -1
- package/lib/libmime.js +19 -4
- package/package.json +6 -6
package/.eslintrc.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v2.1.0 2016-07-24
|
|
4
|
+
|
|
5
|
+
* Changed handling of base64 encoded mime words where multiple words are joined together if possible. This fixes issues with multi byte characters getting split into different mime words (against the RFC but occurs)
|
|
6
|
+
|
|
3
7
|
## v2.0.3 2016-02-29
|
|
4
8
|
|
|
5
9
|
* Fixed an issue with rfc2231 filenames
|
package/lib/charset.js
CHANGED
package/lib/libmime.js
CHANGED
|
@@ -229,14 +229,29 @@ var libmime = module.exports = {
|
|
|
229
229
|
* @return {String} Decoded unicode string
|
|
230
230
|
*/
|
|
231
231
|
decodeWords: function (str) {
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
return (str || '').toString().
|
|
233
|
+
|
|
234
|
+
// find base64 words that can be joined
|
|
235
|
+
replace(/(=\?([^?]+)\?[Bb]\?[^?]+[^^=]\?=)\s*(?==\?([^?]+)\?[Bb]\?[^?]+\?=)/g,
|
|
236
|
+
function (match, left, chLeft, chRight) {
|
|
237
|
+
// only mark to b64 chunks to be joined if charsets match
|
|
238
|
+
if (libcharset.normalizeCharset(chLeft || '').toLowerCase().trim() === libcharset.normalizeCharset(chRight || '').toLowerCase().trim()) {
|
|
239
|
+
// set a joiner marker
|
|
240
|
+
return left + '__\x00JOIN\x00__';
|
|
241
|
+
}
|
|
242
|
+
return match;
|
|
243
|
+
}).
|
|
244
|
+
|
|
245
|
+
// join base64 encoded words
|
|
246
|
+
replace(/(\?=)?__\x00JOIN\x00__(=\?([^?]+)\?[Bb]\?)?/g, '').
|
|
247
|
+
|
|
248
|
+
// remove spaces between mime encoded words
|
|
234
249
|
replace(/(=\?[^?]+\?[QqBb]\?[^?]+\?=)\s+(?==\?[^?]+\?[QqBb]\?[^?]+\?=)/g, '$1').
|
|
250
|
+
|
|
251
|
+
// decode words
|
|
235
252
|
replace(/\=\?([\w_\-\*]+)\?([QqBb])\?[^\?]+\?\=/g, function (mimeWord) {
|
|
236
253
|
return libmime.decodeWord(mimeWord);
|
|
237
254
|
});
|
|
238
|
-
|
|
239
|
-
return str;
|
|
240
255
|
},
|
|
241
256
|
|
|
242
257
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libmime",
|
|
3
3
|
"description": "Encode and decode quoted printable and base64 strings",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"main": "lib/libmime",
|
|
6
6
|
"homepage": "https://github.com/andris9/libmime",
|
|
7
7
|
"repository": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"author": "Andris Reinman <andris@kreata.ee>",
|
|
18
18
|
"scripts": {
|
|
19
|
-
"test": "grunt"
|
|
19
|
+
"test": "grunt mochaTest"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"iconv-lite": "0.4.13",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"chai": "^3.5.0",
|
|
28
|
-
"grunt": "^0.
|
|
29
|
-
"grunt-cli": "^
|
|
30
|
-
"grunt-eslint": "^
|
|
28
|
+
"grunt": "^1.0.1",
|
|
29
|
+
"grunt-cli": "^1.2.0",
|
|
30
|
+
"grunt-eslint": "^19.0.0",
|
|
31
31
|
"grunt-mocha-test": "^0.12.7",
|
|
32
|
-
"mocha": "^
|
|
32
|
+
"mocha": "^3.0.2"
|
|
33
33
|
}
|
|
34
34
|
}
|