imapflow 2.5.7 → 2.5.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
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.5.8](https://github.com/postalsys/imapflow/compare/v2.5.7...v2.5.8) (2026-10-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* use the bundled libmime, libqp, libbase64 and encoding-japanese types ([c1e2e32](https://github.com/postalsys/imapflow/commit/c1e2e328cf0f7926895a83f08640f1b0a4619997))
|
|
9
|
+
|
|
3
10
|
## [2.5.7](https://github.com/postalsys/imapflow/compare/v2.5.6...v2.5.7) (2026-10-19)
|
|
4
11
|
|
|
5
12
|
|
package/dist/cjs/jp-decoder.js
CHANGED
|
@@ -4,9 +4,49 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.JPDecoder = void 0;
|
|
7
|
+
exports.toJapaneseEncoding = toJapaneseEncoding;
|
|
7
8
|
const node_stream_1 = require("node:stream");
|
|
8
9
|
const encoding_japanese_1 = __importDefault(require("encoding-japanese"));
|
|
9
10
|
const limited_passthrough_js_1 = require("./limited-passthrough.js");
|
|
11
|
+
const ENCODING_NAMES = new Set([
|
|
12
|
+
'UTF32',
|
|
13
|
+
'UTF16',
|
|
14
|
+
'UTF16BE',
|
|
15
|
+
'UTF16LE',
|
|
16
|
+
'BINARY',
|
|
17
|
+
'ASCII',
|
|
18
|
+
'JIS',
|
|
19
|
+
'UTF8',
|
|
20
|
+
'EUCJP',
|
|
21
|
+
'SJIS',
|
|
22
|
+
'UNICODE'
|
|
23
|
+
]);
|
|
24
|
+
/**
|
|
25
|
+
* Maps a MIME charset label onto the encoding name encoding-japanese expects.
|
|
26
|
+
*
|
|
27
|
+
* getDecoder() routes the ISO-2022-JP, JIS and EUC-JP families here, including variant labels such
|
|
28
|
+
* as "iso-2022-jp-2" or "euc-jp-ms", and each family maps to the one decoder the library has for it.
|
|
29
|
+
* Shift_JIS labels are mapped too, so the class stays usable on its own. Anything else is left for
|
|
30
|
+
* the library to detect from the bytes.
|
|
31
|
+
*
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
function toJapaneseEncoding(charset) {
|
|
35
|
+
const name = charset.toUpperCase().replace(/[^A-Z0-9]+/g, '');
|
|
36
|
+
if (ENCODING_NAMES.has(name)) {
|
|
37
|
+
return name;
|
|
38
|
+
}
|
|
39
|
+
if (/^EUC/.test(name)) {
|
|
40
|
+
return 'EUCJP';
|
|
41
|
+
}
|
|
42
|
+
if (/^(JIS|ISO2022JP)/.test(name)) {
|
|
43
|
+
return 'JIS';
|
|
44
|
+
}
|
|
45
|
+
if (/^(SHIFTJIS|XSJIS|CP932|MSKANJI|WINDOWS31J)/.test(name)) {
|
|
46
|
+
return 'SJIS';
|
|
47
|
+
}
|
|
48
|
+
return 'AUTO';
|
|
49
|
+
}
|
|
10
50
|
// A Transform stream for decoding Japanese character sets (Shift_JIS, EUC-JP, ISO-2022-JP).
|
|
11
51
|
// Unlike iconv-lite which can decode incrementally, encoding-japanese requires the complete
|
|
12
52
|
// input buffer for accurate charset detection and stateful decoding (especially ISO-2022-JP
|
|
@@ -56,13 +96,10 @@ class JPDecoder extends node_stream_1.Transform {
|
|
|
56
96
|
try {
|
|
57
97
|
let output = encoding_japanese_1.default.convert(input, {
|
|
58
98
|
to: 'UNICODE', // to_encoding
|
|
59
|
-
from: this.charset, // from_encoding
|
|
99
|
+
from: toJapaneseEncoding(this.charset), // from_encoding
|
|
60
100
|
type: 'string'
|
|
61
101
|
});
|
|
62
|
-
|
|
63
|
-
output = Buffer.from(output);
|
|
64
|
-
}
|
|
65
|
-
this.push(output);
|
|
102
|
+
this.push(Buffer.from(output));
|
|
66
103
|
}
|
|
67
104
|
catch {
|
|
68
105
|
// keep as is on errors
|
package/dist/cjs/package-info.js
CHANGED
package/dist/esm/jp-decoder.js
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
import { Transform } from 'node:stream';
|
|
2
2
|
import encodingJapanese from 'encoding-japanese';
|
|
3
3
|
import { normalizeByteLimit } from './limited-passthrough.js';
|
|
4
|
+
const ENCODING_NAMES = new Set([
|
|
5
|
+
'UTF32',
|
|
6
|
+
'UTF16',
|
|
7
|
+
'UTF16BE',
|
|
8
|
+
'UTF16LE',
|
|
9
|
+
'BINARY',
|
|
10
|
+
'ASCII',
|
|
11
|
+
'JIS',
|
|
12
|
+
'UTF8',
|
|
13
|
+
'EUCJP',
|
|
14
|
+
'SJIS',
|
|
15
|
+
'UNICODE'
|
|
16
|
+
]);
|
|
17
|
+
/**
|
|
18
|
+
* Maps a MIME charset label onto the encoding name encoding-japanese expects.
|
|
19
|
+
*
|
|
20
|
+
* getDecoder() routes the ISO-2022-JP, JIS and EUC-JP families here, including variant labels such
|
|
21
|
+
* as "iso-2022-jp-2" or "euc-jp-ms", and each family maps to the one decoder the library has for it.
|
|
22
|
+
* Shift_JIS labels are mapped too, so the class stays usable on its own. Anything else is left for
|
|
23
|
+
* the library to detect from the bytes.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export function toJapaneseEncoding(charset) {
|
|
28
|
+
const name = charset.toUpperCase().replace(/[^A-Z0-9]+/g, '');
|
|
29
|
+
if (ENCODING_NAMES.has(name)) {
|
|
30
|
+
return name;
|
|
31
|
+
}
|
|
32
|
+
if (/^EUC/.test(name)) {
|
|
33
|
+
return 'EUCJP';
|
|
34
|
+
}
|
|
35
|
+
if (/^(JIS|ISO2022JP)/.test(name)) {
|
|
36
|
+
return 'JIS';
|
|
37
|
+
}
|
|
38
|
+
if (/^(SHIFTJIS|XSJIS|CP932|MSKANJI|WINDOWS31J)/.test(name)) {
|
|
39
|
+
return 'SJIS';
|
|
40
|
+
}
|
|
41
|
+
return 'AUTO';
|
|
42
|
+
}
|
|
4
43
|
// A Transform stream for decoding Japanese character sets (Shift_JIS, EUC-JP, ISO-2022-JP).
|
|
5
44
|
// Unlike iconv-lite which can decode incrementally, encoding-japanese requires the complete
|
|
6
45
|
// input buffer for accurate charset detection and stateful decoding (especially ISO-2022-JP
|
|
@@ -50,13 +89,10 @@ export class JPDecoder extends Transform {
|
|
|
50
89
|
try {
|
|
51
90
|
let output = encodingJapanese.convert(input, {
|
|
52
91
|
to: 'UNICODE', // to_encoding
|
|
53
|
-
from: this.charset, // from_encoding
|
|
92
|
+
from: toJapaneseEncoding(this.charset), // from_encoding
|
|
54
93
|
type: 'string'
|
|
55
94
|
});
|
|
56
|
-
|
|
57
|
-
output = Buffer.from(output);
|
|
58
|
-
}
|
|
59
|
-
this.push(output);
|
|
95
|
+
this.push(Buffer.from(output));
|
|
60
96
|
}
|
|
61
97
|
catch {
|
|
62
98
|
// keep as is on errors
|
package/dist/esm/package-info.js
CHANGED