diff --git a/examples/push-message.js b/examples/push-message.js index aae68264..f0bf3cb4 100644 --- a/examples/push-message.js +++ b/examples/push-message.js @@ -41,4 +41,3 @@ transporter.sendMail({ console.log(info); } }); -} diff --git a/imap-core/lib/handler/imap-compile-stream.js b/imap-core/lib/handler/imap-compile-stream.js index 58cb5903..ab723832 100644 --- a/imap-core/lib/handler/imap-compile-stream.js +++ b/imap-core/lib/handler/imap-compile-stream.js @@ -28,7 +28,7 @@ module.exports = function (response, isLogging) { maxLength = maxLength || 0; if (resp.length) { - queue.push(new Buffer(resp)); + queue.push(Buffer.from(resp, 'binary')); lr = resp; resp = ''; } @@ -88,7 +88,7 @@ module.exports = function (response, isLogging) { } else if (typeof value !== 'string') { value = (value || '').toString(); } - output.write(new Buffer(value)); + output.write(Buffer.from(value, 'binary')); return emit(); } }; diff --git a/imap-core/lib/imap-connection.js b/imap-core/lib/imap-connection.js index 6af55ec5..cbab2ac0 100644 --- a/imap-core/lib/imap-connection.js +++ b/imap-core/lib/imap-connection.js @@ -118,7 +118,7 @@ class IMAPConnection extends EventEmitter { */ send(payload, callback) { if (this._socket && this._socket.writable) { - this._socket.write(payload + '\r\n', 'utf-8', callback); + this._socket.write(payload + '\r\n', 'binary', callback); this._server.logger.debug('[%s] S:', this.id, payload); } } diff --git a/imap-core/lib/indexer/indexer.js b/imap-core/lib/indexer/indexer.js index bb449fc1..7d04f6b1 100644 --- a/imap-core/lib/indexer/indexer.js +++ b/imap-core/lib/indexer/indexer.js @@ -50,7 +50,7 @@ class Indexer { data = data.join('\r\n'); } if (data || force) { - size += new Buffer((first ? '' : '\r\n') + (data || ''), 'binary').length; + size += Buffer.from((first ? '' : '\r\n') + (data || ''), 'binary').length; first = false; } }; @@ -126,7 +126,7 @@ class Indexer { data = data.join('\r\n'); } if (remainder || data || force) { - res.write(new Buffer((first ? '' : '\r\n') + (remainder || '') + (data || ''), 'binary')); + res.write(Buffer.from((first ? '' : '\r\n') + (remainder || '') + (data || ''), 'binary')); first = false; } remainder = ''; @@ -423,7 +423,7 @@ class Indexer { }); } else { - return setImmediate(() => callback(null, new Buffer((data || '').toString(), 'binary'))); + return setImmediate(() => callback(null, Buffer.from((data || '').toString(), 'binary'))); } }