From f2c8545293277b382b2d357671e9649e9f7c3b9e Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Thu, 10 Oct 2024 13:13:18 +0300 Subject: [PATCH] fix(idle): Fixed IDLE bug with Outlook --- imap-core/lib/imap-command.js | 15 +++++++++++++++ imap-core/lib/imap-connection.js | 8 +++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/imap-core/lib/imap-command.js b/imap-core/lib/imap-command.js index 1210eab0..192dd407 100644 --- a/imap-core/lib/imap-command.js +++ b/imap-core/lib/imap-command.js @@ -147,6 +147,21 @@ class IMAPCommand { if (command.expecting > maxAllowed) { // APPENDLIMIT response for too large messages // TOOBIG: https://tools.ietf.org/html/rfc4469#section-4.2 + + this.connection?.loggelf({ + short_message: '[TOOBIG] Too big literal used', + _error: 'toobig', + _service: 'imap', + _command: this.command, + _payload: this.payload ? (this.payload.length < 256 ? this.payload : this.payload.toString().substring(0, 256) + '...') : command.value, + _literal_expecting: command.expecting, + _literal_allowed: maxAllowed, + _sess: this.connection?.session?.id, + _user: this.connection?.user?.id, + _cid: this.connection?.id, + _ip: this.remoteAddress + }); + this.connection.send(this.tag + ' NO [TOOBIG] Literal too large'); } else { this.connection.send(this.tag + ' NO Literal too large'); diff --git a/imap-core/lib/imap-connection.js b/imap-core/lib/imap-connection.js index ce478087..4687e381 100644 --- a/imap-core/lib/imap-connection.js +++ b/imap-core/lib/imap-connection.js @@ -505,7 +505,13 @@ class IMAPConnection extends EventEmitter { } if (!command.final) { - currentCommand.append(command, callback); + currentCommand.append(command, (err, ...args) => { + if (err) { + // cancel pending command + this._currentCommand = false; + } + callback(err, ...args); + }); } else { this._currentCommand = false; currentCommand.end(command, callback);