libmime 5.3.7 → 5.3.8
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 +8 -0
- package/README.md +1 -1
- package/lib/charset.js +5 -5
- package/lib/libmime.js +14 -9
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.3.8](https://github.com/nodemailer/libmime/compare/v5.3.7...v5.3.8) (2026-04-08)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* bump iconv-lite to 0.7.2 and refresh dev tooling ([176bde0](https://github.com/nodemailer/libmime/commit/176bde025f4d1ec1dc61266330ed1d2e11457c2c))
|
|
9
|
+
* charset.decode returns string for Japanese encodings ([c2cff8b](https://github.com/nodemailer/libmime/commit/c2cff8b6833d7c0d50d19bb1a63e8db1685cc866))
|
|
10
|
+
|
|
3
11
|
## [5.3.7](https://github.com/nodemailer/libmime/compare/v5.3.6...v5.3.7) (2025-06-26)
|
|
4
12
|
|
|
5
13
|
|
package/README.md
CHANGED
|
@@ -200,7 +200,7 @@ Returns content type for a file extension. If no suitable content types are foun
|
|
|
200
200
|
|
|
201
201
|
**Example**
|
|
202
202
|
|
|
203
|
-
libmime.
|
|
203
|
+
libmime.detectMimeType('logo.jpg') // returns 'image/jpeg'
|
|
204
204
|
|
|
205
205
|
## License
|
|
206
206
|
|
package/lib/charset.js
CHANGED
|
@@ -27,7 +27,7 @@ const charset = (module.exports = {
|
|
|
27
27
|
*
|
|
28
28
|
* @param {Buffer} buf Binary data to be decoded
|
|
29
29
|
* @param {String} [fromCharset='UTF-8'] Binary data is decoded into string using this charset
|
|
30
|
-
* @return {String}
|
|
30
|
+
* @return {String} Decoded string
|
|
31
31
|
*/
|
|
32
32
|
decode(buf, fromCharset) {
|
|
33
33
|
fromCharset = charset.normalizeCharset(fromCharset || 'UTF-8');
|
|
@@ -48,9 +48,9 @@ const charset = (module.exports = {
|
|
|
48
48
|
type: 'string'
|
|
49
49
|
});
|
|
50
50
|
if (typeof output === 'string') {
|
|
51
|
-
|
|
51
|
+
return output;
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
// fall through to iconv-lite if convert returned something unexpected
|
|
54
54
|
} catch (err) {
|
|
55
55
|
// ignore, defaults to iconv-lite on error
|
|
56
56
|
}
|
|
@@ -66,7 +66,7 @@ const charset = (module.exports = {
|
|
|
66
66
|
/**
|
|
67
67
|
* Convert a string from specific encoding to UTF-8 Buffer
|
|
68
68
|
*
|
|
69
|
-
* @param {String|Buffer}
|
|
69
|
+
* @param {String|Buffer} data String or Buffer to be encoded
|
|
70
70
|
* @param {String} [fromCharset='UTF-8'] Source encoding for the string
|
|
71
71
|
* @return {Buffer} UTF-8 encoded typed array
|
|
72
72
|
*/
|
|
@@ -91,7 +91,7 @@ const charset = (module.exports = {
|
|
|
91
91
|
* eg. win-1257 will be converted to WINDOWS-1257
|
|
92
92
|
*
|
|
93
93
|
* @param {String} charset Charset name to convert
|
|
94
|
-
* @return {String}
|
|
94
|
+
* @return {String} Canonicalized charset name
|
|
95
95
|
*/
|
|
96
96
|
normalizeCharset(charset) {
|
|
97
97
|
charset = charset.toLowerCase().trim();
|
package/lib/libmime.js
CHANGED
|
@@ -37,6 +37,7 @@ class Libmime {
|
|
|
37
37
|
* no need to encode the values in any way. If the value is plaintext but has
|
|
38
38
|
* longer lines then allowed, then use format=flowed
|
|
39
39
|
*
|
|
40
|
+
* @param {String} str String to be tested
|
|
40
41
|
* @param {Number} lineLength Max line length to check for
|
|
41
42
|
* @returns {Boolean} Returns true if there is at least one line longer than lineLength chars
|
|
42
43
|
*/
|
|
@@ -195,9 +196,12 @@ class Libmime {
|
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
/**
|
|
198
|
-
*
|
|
199
|
+
* Decodes the inner payload of a single mime encoded-word into a unicode string.
|
|
200
|
+
* Expects the three components of `=?charset?encoding?text?=` already separated.
|
|
199
201
|
*
|
|
200
|
-
* @param {String}
|
|
202
|
+
* @param {String} charset Charset name from the encoded-word (may include an RFC 2231 language tag, which is ignored)
|
|
203
|
+
* @param {String} encoding Encoding indicator, either 'Q' or 'B' (case insensitive)
|
|
204
|
+
* @param {String} str Encoded payload between the second `?` and the trailing `?=`
|
|
201
205
|
* @return {String} Decoded unicode string
|
|
202
206
|
*/
|
|
203
207
|
decodeWord(charset, encoding, str) {
|
|
@@ -257,7 +261,7 @@ class Libmime {
|
|
|
257
261
|
* @param {String|Buffer} data String to be encoded
|
|
258
262
|
* @param {String} mimeWordEncoding='Q' Encoding for the mime word, either Q or B
|
|
259
263
|
* @param {Number} [maxLength=0] If set, split mime words into several chunks if needed
|
|
260
|
-
* @param {String} [fromCharset='UTF-8'] Source
|
|
264
|
+
* @param {String} [fromCharset='UTF-8'] Source character set
|
|
261
265
|
* @return {String} String with possible mime words
|
|
262
266
|
*/
|
|
263
267
|
encodeWords(data, mimeWordEncoding, maxLength, fromCharset) {
|
|
@@ -300,7 +304,7 @@ class Libmime {
|
|
|
300
304
|
/**
|
|
301
305
|
* Decode a string that might include one or several mime words
|
|
302
306
|
*
|
|
303
|
-
* @param {String} str String including some mime words that will be
|
|
307
|
+
* @param {String} str String including some mime words that will be decoded
|
|
304
308
|
* @return {String} Decoded unicode string
|
|
305
309
|
*/
|
|
306
310
|
decodeWords(str) {
|
|
@@ -347,7 +351,7 @@ class Libmime {
|
|
|
347
351
|
* on the rules for the specific header key
|
|
348
352
|
*
|
|
349
353
|
* @param {String} headerLine Single header line, might include linebreaks as well if folded
|
|
350
|
-
* @return {Object}
|
|
354
|
+
* @return {Object} An object of {key, value}
|
|
351
355
|
*/
|
|
352
356
|
decodeHeader(headerLine) {
|
|
353
357
|
let line = (headerLine || '')
|
|
@@ -597,9 +601,10 @@ class Libmime {
|
|
|
597
601
|
* title*0*=utf-8''unicode
|
|
598
602
|
* title*1*=%20string
|
|
599
603
|
*
|
|
604
|
+
* @param {String} key Parameter name (eg. 'filename')
|
|
600
605
|
* @param {String|Buffer} data String to be encoded
|
|
601
606
|
* @param {Number} [maxLength=50] Max length for generated chunks
|
|
602
|
-
* @param {String} [fromCharset='UTF-8'] Source
|
|
607
|
+
* @param {String} [fromCharset='UTF-8'] Source character set
|
|
603
608
|
* @return {Array} A list of encoded keys and headers
|
|
604
609
|
*/
|
|
605
610
|
buildHeaderParam(key, data, maxLength, fromCharset) {
|
|
@@ -763,8 +768,8 @@ class Libmime {
|
|
|
763
768
|
* Returns content type for a file extension. If no suitable content types
|
|
764
769
|
* are found, 'application/octet-stream' is used as the default content type
|
|
765
770
|
*
|
|
766
|
-
* @param {String} extension Extension to be checked for
|
|
767
|
-
* @return {String}
|
|
771
|
+
* @param {String} extension Extension (or filename) to be checked for
|
|
772
|
+
* @return {String} Content type
|
|
768
773
|
*/
|
|
769
774
|
detectMimeType(extension) {
|
|
770
775
|
extension = (extension || '').toString().toLowerCase().replace(/\s/g, '').replace(/^\./g, '').split('.').pop();
|
|
@@ -797,7 +802,7 @@ class Libmime {
|
|
|
797
802
|
*
|
|
798
803
|
* @param {String} str String to be folded
|
|
799
804
|
* @param {Number} [lineLength=76] Maximum length of a line
|
|
800
|
-
* @param {Boolean} afterSpace If true, leave a space in
|
|
805
|
+
* @param {Boolean} afterSpace If true, leave a space in the end of a line
|
|
801
806
|
* @return {String} String with folded lines
|
|
802
807
|
*/
|
|
803
808
|
foldLines(str, lineLength, afterSpace) {
|
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": "5.3.
|
|
4
|
+
"version": "5.3.8",
|
|
5
5
|
"main": "lib/libmime.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"lib",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"encoding-japanese": "2.2.0",
|
|
28
|
-
"iconv-lite": "0.
|
|
28
|
+
"iconv-lite": "0.7.2",
|
|
29
29
|
"libbase64": "1.3.0",
|
|
30
30
|
"libqp": "2.1.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"chai": "4.4.1",
|
|
34
34
|
"eslint-config-nodemailer": "1.2.0",
|
|
35
|
-
"eslint-config-prettier": "10.1.
|
|
35
|
+
"eslint-config-prettier": "10.1.8",
|
|
36
36
|
"grunt": "1.6.1",
|
|
37
37
|
"grunt-cli": "1.5.0",
|
|
38
38
|
"grunt-eslint": "24.3.0",
|
|
39
39
|
"grunt-mocha-test": "0.13.3",
|
|
40
|
-
"mocha": "11.7.
|
|
40
|
+
"mocha": "11.7.5"
|
|
41
41
|
}
|
|
42
42
|
}
|