imapflow 1.0.185 → 1.0.187

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,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.187](https://github.com/postalsys/imapflow/compare/v1.0.186...v1.0.187) (2025-05-20)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * Bumped deps ([6efb9f6](https://github.com/postalsys/imapflow/commit/6efb9f6952ff1f17d80054edb3d46aa43d540756))
9
+
10
+ ## [1.0.186](https://github.com/postalsys/imapflow/compare/v1.0.185...v1.0.186) (2025-04-20)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **parsing:** Limit the depth of nested input ([c6cd7ce](https://github.com/postalsys/imapflow/commit/c6cd7cef9f9b8a1ff137a08e8aebf2555e596a23))
16
+
3
17
  ## [1.0.185](https://github.com/postalsys/imapflow/compare/v1.0.184...v1.0.185) (2025-04-14)
4
18
 
5
19
 
@@ -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/lib/imap-flow.js CHANGED
@@ -1993,7 +1993,7 @@ class ImapFlow extends EventEmitter {
1993
1993
  * @property {String} [unKeyword] Matches messages that do not have the custom flag set
1994
1994
  * @property {Object.<string, Boolean|String>} [header] Matches messages with header key set if value is `true` (**NB!** not supported by all servers) or messages where header partially matches a string value
1995
1995
  * @property {SearchObject} [not] A {@link SearchObject} object. It must not match.
1996
- * @property {SearchObject[]} [or] An array of 2 or more {@link SearchObject} objects. At least on of these must match
1996
+ * @property {SearchObject[]} [or] An array of 2 or more {@link SearchObject} objects. At least one of these must match
1997
1997
  */
1998
1998
 
1999
1999
  /**
package/lib/types.d.ts CHANGED
@@ -905,7 +905,7 @@ declare type SequenceString = string;
905
905
  * @property [unKeyword] - Matches messages that do not have the custom flag set
906
906
  * @property [header] - Matches messages with header key set if value is `true` (**NB!** not supported by all servers) or messages where header partially matches a string value
907
907
  * @property [not] - A {@link SearchObject} object. It must not match.
908
- * @property [or] - An array of 2 or more {@link SearchObject} objects. At least on of these must match
908
+ * @property [or] - An array of 2 or more {@link SearchObject} objects. At least one of these must match
909
909
  */
910
910
  declare type SearchObject = {
911
911
  seq?: SequenceString;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imapflow",
3
- "version": "1.0.185",
3
+ "version": "1.0.187",
4
4
  "description": "IMAP Client for Node",
5
5
  "main": "./lib/imap-flow.js",
6
6
  "scripts": {
@@ -28,11 +28,11 @@
28
28
  },
29
29
  "homepage": "https://imapflow.com/",
30
30
  "devDependencies": {
31
- "@babel/eslint-parser": "7.26.8",
32
- "@babel/eslint-plugin": "7.25.9",
31
+ "@babel/eslint-parser": "7.27.1",
32
+ "@babel/eslint-plugin": "7.27.1",
33
33
  "@babel/plugin-syntax-class-properties": "7.12.13",
34
- "@babel/preset-env": "7.26.9",
35
- "@types/node": "22.13.10",
34
+ "@babel/preset-env": "7.27.2",
35
+ "@types/node": "22.15.19",
36
36
  "eslint": "8.57.0",
37
37
  "eslint-config-nodemailer": "1.2.0",
38
38
  "eslint-config-prettier": "9.1.0",
@@ -52,8 +52,8 @@
52
52
  "libmime": "5.3.6",
53
53
  "libqp": "2.1.1",
54
54
  "mailsplit": "5.4.3",
55
- "nodemailer": "6.10.0",
56
- "pino": "9.6.0",
55
+ "nodemailer": "7.0.3",
56
+ "pino": "9.7.0",
57
57
  "socks": "2.8.4"
58
58
  }
59
59
  }
@@ -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
  };
@@ -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
+ });