From 5297a6edbf2b8a5c539d4e87c4c53d75d0095f43 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Tue, 7 May 2019 10:27:30 +0300 Subject: [PATCH] v1.19.0 --- Gruntfile.js | 3 +++ imap-core/lib/commands/fetch.js | 20 +++++++++++++++++++- imap-core/test/protocol-test.js | 3 ++- lib/handlers/on-fetch.js | 17 +++++++++++++---- package.json | 14 +++++++------- 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 07ae38a0..c57fb6e8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,5 +1,7 @@ 'use strict'; +process.env.NODE_ENV = 'test'; + module.exports = function(grunt) { // Project configuration. grunt.initConfig({ @@ -43,4 +45,5 @@ module.exports = function(grunt) { // Tasks grunt.registerTask('default', ['eslint', 'shell:server', 'wait:server', 'mochaTest', 'shell:server:kill']); + grunt.registerTask('testonly', ['shell:server', 'wait:server', 'mochaTest', 'shell:server:kill']); }; diff --git a/imap-core/lib/commands/fetch.js b/imap-core/lib/commands/fetch.js index 13d00834..4ffa920d 100644 --- a/imap-core/lib/commands/fetch.js +++ b/imap-core/lib/commands/fetch.js @@ -50,6 +50,9 @@ module.exports = { let flagsExist = false; let uidExist = false; let modseqExist = false; + let bodystructureExist = true; + let rfc822sizeExist = true; + let envelopeExist = true; let markAsSeen = false; let metadataOnly = true; let changedSince = 0; @@ -115,6 +118,18 @@ module.exports = { modseqExist = true; } + if (param.value.toUpperCase() === 'BODYSTRUCTURE') { + bodystructureExist = true; + } + + if (param.value.toUpperCase() === 'RFC822.SIZE') { + rfc822sizeExist = true; + } + + if (param.value.toUpperCase() === 'ENVELOPE') { + envelopeExist = true; + } + if (!this.selected.readOnly) { if (param.value.toUpperCase() === 'BODY' && param.section) { // BODY[...] @@ -129,7 +144,7 @@ module.exports = { param.value = 'BODY'; } - if (['BODY', 'RFC822', 'RFC822.SIZE', 'RFC822.HEADER', 'RFC822.TEXT', 'BODYSTRUCTURE'].indexOf(param.value.toUpperCase()) >= 0) { + if (['BODY', 'RFC822', 'RFC822.HEADER', 'RFC822.TEXT'].indexOf(param.value.toUpperCase()) >= 0) { metadataOnly = false; } } @@ -257,6 +272,9 @@ module.exports = { this._server.onFetch( this.selected.mailbox, { + bodystructureExist, + rfc822sizeExist, + envelopeExist, metadataOnly: !!metadataOnly, markAsSeen: !!markAsSeen, messages, diff --git a/imap-core/test/protocol-test.js b/imap-core/test/protocol-test.js index a7e7384e..7504ef29 100644 --- a/imap-core/test/protocol-test.js +++ b/imap-core/test/protocol-test.js @@ -1211,7 +1211,7 @@ describe('IMAP Protocol integration tests', function() { describe('Multiple values', function() { it('should list mixed data', function(done) { let cmds = ['T1 LOGIN testuser pass', 'T2 SELECT INBOX', 'T3 FETCH 1:* (UID BODYSTRUCTURE ENVELOPE)', 'T4 LOGOUT']; - + console.log(cmds); testClient( { commands: cmds, @@ -1220,6 +1220,7 @@ describe('IMAP Protocol integration tests', function() { }, function(resp) { resp = resp.toString(); + console.log(resp); expect( resp .slice(/\n/) diff --git a/lib/handlers/on-fetch.js b/lib/handlers/on-fetch.js index 530c7d1b..5c0d6386 100644 --- a/lib/handlers/on-fetch.js +++ b/lib/handlers/on-fetch.js @@ -55,12 +55,21 @@ module.exports = (server, messageHandler, userCache) => (mailbox, options, sessi uid: true, modseq: true, idate: true, - flags: true, - envelope: true, - bodystructure: true, - size: true + flags: true }; + if (options.bodystructureExist) { + projection.bodystructure = true; + } + + if (options.rfc822sizeExist) { + projection.size = true; + } + + if (options.envelopeExist) { + projection.envelope = true; + } + if (!options.metadataOnly) { projection.mimeTree = true; } diff --git a/package.json b/package.json index 3ab36de7..23601824 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wildduck", - "version": "1.18.1", + "version": "1.19.0", "description": "IMAP/POP3 server built with Node.js and MongoDB", "main": "server.js", "scripts": { @@ -29,8 +29,8 @@ "grunt-shell-spawn": "0.4.0", "grunt-wait": "0.3.0", "icedfrisby": "1.5.0", - "mailparser": "2.6.0", - "mocha": "5.2.0", + "mailparser": "2.7.1", + "mocha": "6.1.4", "request": "2.88.0" }, "dependencies": { @@ -51,9 +51,9 @@ "js-yaml": "3.13.1", "key-fingerprint": "1.1.0", "libbase64": "1.0.3", - "libmime": "4.0.1", + "libmime": "4.1.1", "libqp": "1.1.0", - "mailsplit": "4.3.1", + "mailsplit": "4.4.1", "mobileconfig": "2.2.0", "mongo-cursor-pagination": "7.1.0", "mongodb": "3.2.3", @@ -61,11 +61,11 @@ "node-forge": "0.8.2", "nodemailer": "6.1.1", "npmlog": "4.1.2", - "openpgp": "4.4.10", + "openpgp": "4.5.1", "pem": "1.14.2", "pwnedpasswords": "1.0.4", "qrcode": "1.3.3", - "restify": "8.3.1", + "restify": "8.3.2", "restify-logger": "2.0.1", "seq-index": "1.1.0", "smtp-server": "3.5.0",