Skip to content

Commit

Permalink
Merge branch 'master' into ZMS-118
Browse files Browse the repository at this point in the history
  • Loading branch information
NickOvt authored Jan 2, 2024
2 parents b0d0e7b + fae91d1 commit 5165f3e
Show file tree
Hide file tree
Showing 23 changed files with 2,033 additions and 1,049 deletions.
8 changes: 7 additions & 1 deletion .ncurc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ module.exports = {
upgrade: true,
reject: [
// mongodb 5.x driver does not support callbacks, only promises
'mongodb'
'mongodb',

// no support for Node 16
'undici',

// esm
'chai'
]
};
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# Changelog

## [1.41.3](https://github.com/nodemailer/wildduck/compare/v1.41.2...v1.41.3) (2023-12-19)


### Bug Fixes

* **api:** Remove unnecessary required() that brakes the e-mail send ([#580](https://github.com/nodemailer/wildduck/issues/580)) ([d80ba77](https://github.com/nodemailer/wildduck/commit/d80ba77650f539a47e5a7c28cfd9c9d0de48b3e4))

## [1.41.2](https://github.com/nodemailer/wildduck/compare/v1.41.1...v1.41.2) (2023-12-15)


### Bug Fixes

* **upload:** allow empty name field in the Upload message FROM: header ZMS-113 ([#577](https://github.com/nodemailer/wildduck/issues/577)) ([c1e28db](https://github.com/nodemailer/wildduck/commit/c1e28db0f3d37b507e7aaef6b26557b27f7ab2f3))

## [1.41.1](https://github.com/nodemailer/wildduck/compare/v1.41.0...v1.41.1) (2023-12-14)


### Bug Fixes

* **defer:** Added new setting const:sender:defer_times ZMS 63 ([#574](https://github.com/nodemailer/wildduck/issues/574)) ([9aab242](https://github.com/nodemailer/wildduck/commit/9aab24267b8c90d7d1af30fcace8c60704e1ea27))
* **mime-parsing:** ensure that text content for multipart nodes always ends with a newline. Fixes [#571](https://github.com/nodemailer/wildduck/issues/571) ([6f4994d](https://github.com/nodemailer/wildduck/commit/6f4994d3a00c8ec73921b443aee4c2cc65561922))

## [1.41.0](https://github.com/nodemailer/wildduck/compare/v1.40.10...v1.41.0) (2023-11-30)


### Features

* **apidocs:** Autogenerate OpenAPI docs ZMS-100 ([#552](https://github.com/nodemailer/wildduck/issues/552)) ([ea24b93](https://github.com/nodemailer/wildduck/commit/ea24b9328b6984db841de86309f1712f100acb97))
* **docs:** ZMS-[9x] Automatic API generation ([#535](https://github.com/nodemailer/wildduck/issues/535)) ([c1cc143](https://github.com/nodemailer/wildduck/commit/c1cc143663bc8ad81794eb9bf4cee04a37937899))
* **mailbox-count-limit:** Set a limit for maximum number of mailbox folders ZMS-93 ([#542](https://github.com/nodemailer/wildduck/issues/542)) ([779bb11](https://github.com/nodemailer/wildduck/commit/779bb11e831eb902330db3ed9056f90aeba4234c))


### Bug Fixes

* **addressregister:** Do not add no-reply addresses to the addressregister ZMS-99 ([#551](https://github.com/nodemailer/wildduck/issues/551)) ([be24af0](https://github.com/nodemailer/wildduck/commit/be24af0d2665fb27f85ff0f0435e4480c21575fa))
* **audit:** Fixed `find()` query for expired audits ([#547](https://github.com/nodemailer/wildduck/issues/547)) ([48b9efb](https://github.com/nodemailer/wildduck/commit/48b9efb8ca4b300597b2e8f5ef4aa307ac97dcfe))
* **docs:** Added support for enums ZMS-104 ([#565](https://github.com/nodemailer/wildduck/issues/565)) ([28bdc76](https://github.com/nodemailer/wildduck/commit/28bdc7621e13a96965a2a24caee873cf15b8aa31))
* **docs:** Fixed descriptions ZMS-101 ([#553](https://github.com/nodemailer/wildduck/issues/553)) ([3c9e175](https://github.com/nodemailer/wildduck/commit/3c9e17595cffd32475f51aa104ab09d721989e6f))
* **imap-search:** rename `headerdate` to `date` (closes [#560](https://github.com/nodemailer/wildduck/issues/560)) ([#561](https://github.com/nodemailer/wildduck/issues/561)) ([fd98244](https://github.com/nodemailer/wildduck/commit/fd98244342089dc8a587e3e45b559f12f8764140))
* **imap:** fixed string conversion to utf8 vs binary (closes [#563](https://github.com/nodemailer/wildduck/issues/563)) ([#564](https://github.com/nodemailer/wildduck/issues/564)) ([ee2708e](https://github.com/nodemailer/wildduck/commit/ee2708e4c150f79745a2a81e3e4555a7549c426d))
* **mailbox-create:** Use correct database for loading User data when creating mailboxes ([#550](https://github.com/nodemailer/wildduck/issues/550)) ([4434cb5](https://github.com/nodemailer/wildduck/commit/4434cb5e1ff4414da874b62997da5ea41892a286))

## [1.40.10](https://github.com/nodemailer/wildduck/compare/v1.40.9...v1.40.10) (2023-10-16)


Expand Down
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,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']);
grunt.registerTask('proto', ['mochaTest:imap']);
};
9 changes: 6 additions & 3 deletions docs/api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,9 @@ paths:
content:
application/octet-stream:
schema:
type: binary
type: string
description: Success
format: binary

/data/import:
post:
Expand All @@ -1319,7 +1321,9 @@ paths:
content:
application/octet-stream:
schema:
type: binary
type: string
description: Success
format: binary
required: true
responses:
'200':
Expand Down Expand Up @@ -2105,7 +2109,6 @@ paths:
description: 'Partial match for the From: header line'
type: string
to:
in: query
description: 'Partial match for the To: and Cc: header lines'
type: string
subject:
Expand Down
12 changes: 11 additions & 1 deletion imap-core/lib/imap-composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,17 @@ class IMAPComposer extends Transform {
);
}

this.push(Buffer.from(compiled + '\r\n', 'binary'));
// <https://github.com/nodemailer/wildduck/issues/563>
// <https://github.com/nodemailer/wildduck/pull/564
if (typeof compiled === 'object') {
this.push(compiled);
this.push('\r\n');
} else if (typeof compiled === 'string') {
this.push(Buffer.from(compiled + '\r\n', 'binary'));
} else {
return done(new TypeError('"compiled" was not an object or string'));
}

done();
}

Expand Down
17 changes: 17 additions & 0 deletions imap-core/lib/indexer/parse-mime-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,23 @@ class MIMEParser {
node.message = parse(node.body.join(''));
}

if (node.body && node.body.length && node.multipart) {
// find last character from an array of strings
let lastChar;
let lastIndex = 0;
for (let i = node.body.length - 1; i >= 0; i--) {
if (typeof node.body[i] === 'string' && node.body[i].length) {
lastChar = node.body[i].at(-1);
lastIndex = i;
break;
}
}
if (lastChar && lastChar !== '\n') {
// ensure that non-multipart body text always ends with a newline
node.body[lastIndex] += '\n';
}
}

node.lineCount = node.body.length ? node.body.length - 1 : 0;
node.body = Buffer.from(
node.body
Expand Down
22 changes: 22 additions & 0 deletions imap-core/test/fixtures/no_empty_line_between_text_boundary.eml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Content-Type: multipart/mixed; boundary="------------cWFvDSey27tFG0hVYLqp9hs9"
MIME-Version: 1.0
Message-ID: <[email protected]>
To: [email protected]
From: [email protected]
Subject: test

This is a multi-part message in MIME format.
--------------cWFvDSey27tFG0hVYLqp9hs9
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
test
--------------cWFvDSey27tFG0hVYLqp9hs9
Content-Type: text/plain; charset=UTF-8; name="example.txt"
Content-Disposition: attachment; filename="example.txt"
Content-Transfer-Encoding: base64
ZXhhbXBsZQo=
--------------cWFvDSey27tFG0hVYLqp9hs9--
28 changes: 28 additions & 0 deletions imap-core/test/parse-mime-tree-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@
'use strict';

const MIMEParser = require('../lib/indexer/parse-mime-tree').MIMEParser;
const Indexer = require('../lib/indexer/indexer');
const indexer = new Indexer();

const fs = require('fs');
const chai = require('chai');
const expect = chai.expect;
chai.config.includeStack = true;

const fixtures = {
no_empty_line_between_text_boundary: {
eml: fs.readFileSync(__dirname + '/fixtures/no_empty_line_between_text_boundary.eml')
}
};

describe('#parseValueParams', function () {
it('should return continuation value as mime-word', function () {
let parser = new MIMEParser();
Expand Down Expand Up @@ -44,4 +53,23 @@ describe('#parseValueParams', function () {
hasParams: true
});
});

it('should parse a file with no empty line between text and boundary', function (done) {
// parse a file and then make sure that boundary is correct

let source = Buffer.concat([fixtures.no_empty_line_between_text_boundary.eml]);

let parser = new MIMEParser(source);

parser.parse();
parser.finalizeTree();

let parsed = parser.tree.childNodes[0];

indexer.bodyQuery(parsed, '', (err, data) => {
expect(err).to.not.exist;
expect(data.toString().indexOf('This is a multi-part message in MIME format.\r\n--------------cWFvDSey27tFG0hVYLqp9hs9')).to.gt(0);
done();
});
});
});
14 changes: 11 additions & 3 deletions lib/api/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ const { getMongoDBQuery /*, getElasticSearchQuery*/ } = require('../search-query
//const { getClient } = require('../elasticsearch');

const BimiHandler = require('../bimi-handler');
const { Address, AddressOptionalNameArray, Header, Attachment, ReferenceWithAttachments, Bimi } = require('../schemas/request/messages-schemas');
const {
Address,
AddressOptionalNameArray,
Header,
Attachment,
ReferenceWithAttachments,
Bimi,
AddressOptionalName
} = require('../schemas/request/messages-schemas');
const { userId, mailboxId, messageId } = require('../schemas/request/general-schemas');
const { MsgEnvelope } = require('../schemas/response/messages-schemas');
const { successRes } = require('../schemas/response/general-schemas');
Expand Down Expand Up @@ -1895,9 +1903,9 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti
'base64 encoded message source. Alternatively, you can provide this value as POST body by using message/rfc822 MIME type. If raw message is provided then it overrides any other mail configuration'
),

from: Address.description('Addres for the From: header'),
from: AddressOptionalName.description('Addres for the From: header'),

replyTo: Address.description('Address for the Reply-To: header'),
replyTo: AddressOptionalName.description('Address for the Reply-To: header'),

to: AddressOptionalNameArray.description('Addresses for the To: header'),

Expand Down
Loading

0 comments on commit 5165f3e

Please sign in to comment.