From 93857d4edb56876efda64efb3177b64e037e08aa Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Fri, 27 Oct 2017 12:45:57 +0300 Subject: [PATCH] Fixes #32 --- imap-core/lib/handler/imap-compile-stream.js | 2 +- imap-core/lib/indexer/indexer.js | 6 +++++- imap-core/test/protocol-test.js | 2 +- lib/filter-handler.js | 5 ++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/imap-core/lib/handler/imap-compile-stream.js b/imap-core/lib/handler/imap-compile-stream.js index 337d4028..0d6e89a0 100644 --- a/imap-core/lib/handler/imap-compile-stream.js +++ b/imap-core/lib/handler/imap-compile-stream.js @@ -216,7 +216,7 @@ module.exports = function(response, isLogging) { let finalize = () => { if (node.partial) { - resp += '<' + node.partial.join('.') + '>'; + resp += '<' + node.partial[0] + '>'; } setImmediate(callback); }; diff --git a/imap-core/lib/indexer/indexer.js b/imap-core/lib/indexer/indexer.js index 9becc9fb..c8561944 100644 --- a/imap-core/lib/indexer/indexer.js +++ b/imap-core/lib/indexer/indexer.js @@ -370,7 +370,7 @@ class Indexer { // remove attachments and very large text nodes from the mime tree if (!isMultipart && node.body && node.body.length && (!isInlineText || node.size > 300 * 1024)) { - let attachmentId = 'ATT' + (++idcount).toString().padStart(5, '0'); + let attachmentId = 'ATT' + leftPad(++idcount, '0', 5); let fileName = (node.parsedHeader['content-disposition'] && @@ -784,4 +784,8 @@ function textToHtml(str) { return text; } +function leftPad(val, chr, len) { + return chr.repeat(len - val.toString().length) + val; +} + module.exports = Indexer; diff --git a/imap-core/test/protocol-test.js b/imap-core/test/protocol-test.js index 5d3c3d38..42b6e6fd 100644 --- a/imap-core/test/protocol-test.js +++ b/imap-core/test/protocol-test.js @@ -1364,7 +1364,7 @@ describe('IMAP Protocol integration tests', function() { }, function(resp) { resp = resp.toString(); - expect(resp.indexOf('\n* 4 FETCH (BODY[]<4.5> {5}\r\n: sen)\r\n') >= 0).to.be.true; + expect(resp.indexOf('\n* 4 FETCH (BODY[]<4> {5}\r\n: sen)\r\n') >= 0).to.be.true; expect( resp.indexOf( '\n* 4 FETCH (BODY[]<4> {93}\r\n: sender@example.com\r\nto: to@example.com\r\ncc: cc@example.com\r\nsubject: test\r\n\r\nHello World!\r\n)\r\n' diff --git a/lib/filter-handler.js b/lib/filter-handler.js index 17b7af77..8e6ae6e1 100644 --- a/lib/filter-handler.js +++ b/lib/filter-handler.js @@ -311,10 +311,9 @@ class FilterHandler { recipient, targets: forwardTargets.size - ? Array.from(forwardTargets).map((row, i) => ({ + ? Array.from(forwardTargets).map(row => ({ type: row[1].type, - value: row[1].value, - seq: (i + 1).toString(16).padStart(3, '0') + value: row[1].value })) : false,