imapflow 1.0.185 → 1.0.186
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 +7 -0
- package/lib/commands/append.js +4 -3
- package/lib/handler/token-parser.js +12 -0
- package/package.json +1 -1
- package/test/bodystructure-test.js +0 -2
- package/test/imap-parser-test.js +13 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.186](https://github.com/postalsys/imapflow/compare/v1.0.185...v1.0.186) (2025-04-20)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **parsing:** Limit the depth of nested input ([c6cd7ce](https://github.com/postalsys/imapflow/commit/c6cd7cef9f9b8a1ff137a08e8aebf2555e596a23))
|
|
9
|
+
|
|
3
10
|
## [1.0.185](https://github.com/postalsys/imapflow/compare/v1.0.184...v1.0.185) (2025-04-14)
|
|
4
11
|
|
|
5
12
|
|
package/lib/commands/append.js
CHANGED
|
@@ -9,6 +9,10 @@ module.exports = async (connection, destination, content, flags, idate) => {
|
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
if (typeof content === 'string') {
|
|
13
|
+
content = Buffer.from(content);
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
if (connection.capabilities.has('APPENDLIMIT')) {
|
|
13
17
|
let appendLimit = connection.capabilities.get('APPENDLIMIT');
|
|
14
18
|
if (typeof appendLimit === 'number' && appendLimit < content.length) {
|
|
@@ -40,9 +44,6 @@ module.exports = async (connection, destination, content, flags, idate) => {
|
|
|
40
44
|
|
|
41
45
|
let isLiteral8 = false;
|
|
42
46
|
if (connection.capabilities.has('BINARY') && !connection.disableBinary) {
|
|
43
|
-
if (typeof content === 'string') {
|
|
44
|
-
content = Buffer.from(content);
|
|
45
|
-
}
|
|
46
47
|
// Value is literal8 if it contains NULL bytes. The server must support the BINARY extension
|
|
47
48
|
// and if it does not then send the value as a regular literal and hope for the best
|
|
48
49
|
isLiteral8 = content.indexOf(Buffer.from([0])) >= 0;
|
|
@@ -15,6 +15,8 @@ const STATE_TEXT = 0x007;
|
|
|
15
15
|
const RE_DIGITS = /^\d+$/;
|
|
16
16
|
const RE_SINGLE_DIGIT = /^\d$/;
|
|
17
17
|
|
|
18
|
+
const MAX_NODE_DEPTH = 25;
|
|
19
|
+
|
|
18
20
|
class TokenParser {
|
|
19
21
|
constructor(parent, startPos, str, options) {
|
|
20
22
|
this.str = (str || '').toString();
|
|
@@ -116,6 +118,16 @@ class TokenParser {
|
|
|
116
118
|
|
|
117
119
|
if (parentNode) {
|
|
118
120
|
node.parentNode = parentNode;
|
|
121
|
+
node.depth = parentNode.depth + 1;
|
|
122
|
+
} else {
|
|
123
|
+
node.depth = 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (node.depth > MAX_NODE_DEPTH) {
|
|
127
|
+
let error = new Error('Too much nesting in IMAP string');
|
|
128
|
+
error.code = 'MAX_IMAP_NESTING_REACHED';
|
|
129
|
+
error._imapStr = this.str;
|
|
130
|
+
throw error;
|
|
119
131
|
}
|
|
120
132
|
|
|
121
133
|
if (typeof startPos === 'number') {
|
package/package.json
CHANGED
|
@@ -1125,8 +1125,6 @@ module.exports['Process non-standard unicode filename property'] = test => {
|
|
|
1125
1125
|
|
|
1126
1126
|
let bodyStruct = parseBodystructure(attribute);
|
|
1127
1127
|
|
|
1128
|
-
console.log(JSON.stringify(bodyStruct, false, 2));
|
|
1129
|
-
|
|
1130
1128
|
test.deepEqual(bodyStruct.childNodes[1].dispositionParameters.filename, 'Trang_ghi_âm (8) (1).xlsx');
|
|
1131
1129
|
test.done();
|
|
1132
1130
|
};
|
package/test/imap-parser-test.js
CHANGED
|
@@ -981,7 +981,6 @@ module.exports['IMAP Parser, NO with a dot'] = test =>
|
|
|
981
981
|
module.exports['IMAP Parser, no tag or response (Exchange)'] = test =>
|
|
982
982
|
asyncWrapper(test, async test => {
|
|
983
983
|
let parsed = await parser('Server Unavailable. 15');
|
|
984
|
-
console.log(parsed);
|
|
985
984
|
test.equal(parsed.command, 'BAD');
|
|
986
985
|
test.deepEqual(parsed.attributes, [{ type: 'TEXT', value: 'Server Unavailable. 15' }]);
|
|
987
986
|
});
|
|
@@ -1237,3 +1236,16 @@ module.exports['IMAP Parser, FETCH with BODYSTRUCTURE'] = test =>
|
|
|
1237
1236
|
]
|
|
1238
1237
|
]);
|
|
1239
1238
|
});
|
|
1239
|
+
|
|
1240
|
+
module.exports['IMAP Parser, FETCH with BODYSTRUCTURE'] = test =>
|
|
1241
|
+
asyncWrapper(test, async test => {
|
|
1242
|
+
try {
|
|
1243
|
+
let parsed = await parser('* 1 FETCH (UID 1 (((((((((((((((((((((((((');
|
|
1244
|
+
test.ok(!parsed);
|
|
1245
|
+
} catch (err) {
|
|
1246
|
+
test.ok(err);
|
|
1247
|
+
if (err.code !== 'MAX_IMAP_NESTING_REACHED') {
|
|
1248
|
+
throw err;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
});
|