mirror of
https://github.com/nodemailer/wildduck.git
synced 2024-09-20 15:26:03 +08:00
make sure that there is no WS bertween BODYSTRUCTURE lists
This commit is contained in:
parent
8f2fdd8abf
commit
01463cf386
|
@ -1 +1 @@
|
||||||
define({
"name": "wildduck",
"version": "1.0.0",
"description": "WildDuck API docs",
"title": "WildDuck API",
"url": "https://api.wildduck.email",
"sampleUrl": false,
"defaultVersion": "0.0.0",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2019-01-18T12:25:12.222Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
});
|
define({
"name": "wildduck",
"version": "1.0.0",
"description": "WildDuck API docs",
"title": "WildDuck API",
"url": "https://api.wildduck.email",
"sampleUrl": false,
"defaultVersion": "0.0.0",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2019-02-05T18:57:01.438Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
});
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{
"name": "wildduck",
"version": "1.0.0",
"description": "WildDuck API docs",
"title": "WildDuck API",
"url": "https://api.wildduck.email",
"sampleUrl": false,
"defaultVersion": "0.0.0",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2019-01-18T12:25:12.222Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
}
|
{
"name": "wildduck",
"version": "1.0.0",
"description": "WildDuck API docs",
"title": "WildDuck API",
"url": "https://api.wildduck.email",
"sampleUrl": false,
"defaultVersion": "0.0.0",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2019-02-05T18:57:01.438Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
}
|
||||||
|
|
|
@ -72,9 +72,12 @@ module.exports = function(response, isLogging) {
|
||||||
|
|
||||||
let limiter = new LengthLimiter(expectedLength, ' ', startFrom);
|
let limiter = new LengthLimiter(expectedLength, ' ', startFrom);
|
||||||
|
|
||||||
value.stream.pipe(limiter).pipe(output, {
|
value.stream.pipe(limiter).pipe(
|
||||||
end: false
|
output,
|
||||||
});
|
{
|
||||||
|
end: false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// pass errors to output
|
// pass errors to output
|
||||||
value.stream.once('error', err => {
|
value.stream.once('error', err => {
|
||||||
|
@ -99,9 +102,14 @@ module.exports = function(response, isLogging) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let walk = function(node, callback) {
|
let walk = function(node, options, callback) {
|
||||||
if (lastType === 'LITERAL' || (['(', '<', '['].indexOf((resp || lr).substr(-1)) < 0 && (resp || lr).length)) {
|
options = options || {};
|
||||||
resp += ' ';
|
if (lastType === 'LITERAL' || (!['(', '<', '['].includes((resp || lr).substr(-1)) && (resp || lr).length)) {
|
||||||
|
if (options.subArray) {
|
||||||
|
// ignore separator
|
||||||
|
} else {
|
||||||
|
resp += ' ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node && node.buffer && !Buffer.isBuffer(node)) {
|
if (node && node.buffer && !Buffer.isBuffer(node)) {
|
||||||
|
@ -113,13 +121,21 @@ module.exports = function(response, isLogging) {
|
||||||
lastType = 'LIST';
|
lastType = 'LIST';
|
||||||
resp += '(';
|
resp += '(';
|
||||||
|
|
||||||
|
// check if we need to skip separtor WS between two arrays
|
||||||
|
let subArray = node.length > 1 && Array.isArray(node[0]);
|
||||||
|
|
||||||
let pos = 0;
|
let pos = 0;
|
||||||
let next = () => {
|
let next = () => {
|
||||||
if (pos >= node.length) {
|
if (pos >= node.length) {
|
||||||
resp += ')';
|
resp += ')';
|
||||||
return setImmediate(callback);
|
return setImmediate(callback);
|
||||||
}
|
}
|
||||||
walk(node[pos++], next);
|
let child = node[pos++];
|
||||||
|
|
||||||
|
if (subArray && !Array.isArray(child)) {
|
||||||
|
subArray = false;
|
||||||
|
}
|
||||||
|
walk(child, { subArray }, next);
|
||||||
};
|
};
|
||||||
|
|
||||||
return setImmediate(next);
|
return setImmediate(next);
|
||||||
|
@ -230,7 +246,7 @@ module.exports = function(response, isLogging) {
|
||||||
resp += ']';
|
resp += ']';
|
||||||
return setImmediate(finalize);
|
return setImmediate(finalize);
|
||||||
}
|
}
|
||||||
walk(node.section[pos++], next);
|
walk(node.section[pos++], false, next);
|
||||||
};
|
};
|
||||||
|
|
||||||
return setImmediate(next);
|
return setImmediate(next);
|
||||||
|
@ -252,7 +268,7 @@ module.exports = function(response, isLogging) {
|
||||||
if (pos >= attribs.length) {
|
if (pos >= attribs.length) {
|
||||||
return setImmediate(finalize);
|
return setImmediate(finalize);
|
||||||
}
|
}
|
||||||
walk(attribs[pos++], next);
|
walk(attribs[pos++], false, next);
|
||||||
};
|
};
|
||||||
setImmediate(next);
|
setImmediate(next);
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,15 @@ module.exports = function(response, asArray, isLogging) {
|
||||||
let resp = (response.tag || '') + (response.command ? ' ' + response.command : '');
|
let resp = (response.tag || '') + (response.command ? ' ' + response.command : '');
|
||||||
let val;
|
let val;
|
||||||
let lastType;
|
let lastType;
|
||||||
let walk = function(node) {
|
let walk = function(node, options) {
|
||||||
if (lastType === 'LITERAL' || (['(', '<', '['].indexOf(resp.substr(-1)) < 0 && resp.length)) {
|
options = options || {};
|
||||||
resp += ' ';
|
|
||||||
|
if (lastType === 'LITERAL' || (!['(', '<', '['].includes(resp.substr(-1)) && resp.length)) {
|
||||||
|
if (options.subArray) {
|
||||||
|
// ignore separator
|
||||||
|
} else {
|
||||||
|
resp += ' ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node && node.buffer && !Buffer.isBuffer(node)) {
|
if (node && node.buffer && !Buffer.isBuffer(node)) {
|
||||||
|
@ -25,7 +31,16 @@ module.exports = function(response, asArray, isLogging) {
|
||||||
if (Array.isArray(node)) {
|
if (Array.isArray(node)) {
|
||||||
lastType = 'LIST';
|
lastType = 'LIST';
|
||||||
resp += '(';
|
resp += '(';
|
||||||
node.forEach(walk);
|
|
||||||
|
// check if we need to skip separtor WS between two arrays
|
||||||
|
let subArray = node.length > 1 && Array.isArray(node[0]);
|
||||||
|
|
||||||
|
node.forEach(child => {
|
||||||
|
if (subArray && !Array.isArray(child)) {
|
||||||
|
subArray = false;
|
||||||
|
}
|
||||||
|
walk(child, { subArray });
|
||||||
|
});
|
||||||
resp += ')';
|
resp += ')';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +114,7 @@ module.exports = function(response, asArray, isLogging) {
|
||||||
|
|
||||||
if (node.section) {
|
if (node.section) {
|
||||||
resp += '[';
|
resp += '[';
|
||||||
node.section.forEach(walk);
|
node.section.forEach(child => walk(child));
|
||||||
resp += ']';
|
resp += ']';
|
||||||
}
|
}
|
||||||
if (node.partial) {
|
if (node.partial) {
|
||||||
|
@ -109,7 +124,7 @@ module.exports = function(response, asArray, isLogging) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
[].concat(response.attributes || []).forEach(walk);
|
[].concat(response.attributes || []).forEach(child => walk(child));
|
||||||
|
|
||||||
if (resp.length) {
|
if (resp.length) {
|
||||||
respParts.push(resp);
|
respParts.push(resp);
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe('IMAP Command Compile Stream', function() {
|
||||||
describe('#compile', function() {
|
describe('#compile', function() {
|
||||||
it('should compile correctly', function(done) {
|
it('should compile correctly', function(done) {
|
||||||
let command =
|
let command =
|
||||||
'* FETCH (ENVELOPE ("Mon, 2 Sep 2013 05:30:13 -0700 (PDT)" NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "tr.ee")) NIL NIL NIL "<-4730417346358914070@unknownmsgid>") BODYSTRUCTURE (("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 105 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "<test1>" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 5 NIL NIL NIL) ("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 83 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "NIL" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 4 NIL NIL NIL) ("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "QUOTED-PRINTABLE" 19 0 NIL NIL NIL) "MIXED" ("BOUNDARY" "----mailcomposer-?=_1-1328088797399") NIL NIL))',
|
'* FETCH (ENVELOPE ("Mon, 2 Sep 2013 05:30:13 -0700 (PDT)" NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "tr.ee")) NIL NIL NIL "<-4730417346358914070@unknownmsgid>") BODYSTRUCTURE (("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 105 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "<test1>" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 5 NIL NIL NIL)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 83 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "NIL" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 4 NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "QUOTED-PRINTABLE" 19 0 NIL NIL NIL) "MIXED" ("BOUNDARY" "----mailcomposer-?=_1-1328088797399") NIL NIL))',
|
||||||
parsed = imapHandler.parser(command, {
|
parsed = imapHandler.parser(command, {
|
||||||
allowUntagged: true
|
allowUntagged: true
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe('IMAP Command Compiler', function() {
|
||||||
describe('#compile', function() {
|
describe('#compile', function() {
|
||||||
it('should compile correctly', function() {
|
it('should compile correctly', function() {
|
||||||
let command =
|
let command =
|
||||||
'* FETCH (ENVELOPE ("Mon, 2 Sep 2013 05:30:13 -0700 (PDT)" NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "tr.ee")) NIL NIL NIL "<-4730417346358914070@unknownmsgid>") BODYSTRUCTURE (("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 105 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "<test1>" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 5 NIL NIL NIL) ("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 83 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "NIL" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 4 NIL NIL NIL) ("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "QUOTED-PRINTABLE" 19 0 NIL NIL NIL) "MIXED" ("BOUNDARY" "----mailcomposer-?=_1-1328088797399") NIL NIL))',
|
'* FETCH (ENVELOPE ("Mon, 2 Sep 2013 05:30:13 -0700 (PDT)" NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "tr.ee")) NIL NIL NIL "<-4730417346358914070@unknownmsgid>") BODYSTRUCTURE (("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 105 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "<test1>" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 5 NIL NIL NIL)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 83 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "NIL" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 4 NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "QUOTED-PRINTABLE" 19 0 NIL NIL NIL) "MIXED" ("BOUNDARY" "----mailcomposer-?=_1-1328088797399") NIL NIL))',
|
||||||
parsed = imapHandler.parser(command, {
|
parsed = imapHandler.parser(command, {
|
||||||
allowUntagged: true
|
allowUntagged: true
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -1323,7 +1323,7 @@ describe('IMAP Protocol integration tests', function() {
|
||||||
resp = resp.toString();
|
resp = resp.toString();
|
||||||
expect(
|
expect(
|
||||||
resp.indexOf(
|
resp.indexOf(
|
||||||
'\n* 3 FETCH (BODYSTRUCTURE (("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 107 (NIL "" ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "<test1>" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 14 0 NIL NIL NIL NIL) 5 NIL NIL NIL NIL) ("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 85 (NIL "" ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL NIL NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 14 0 NIL NIL NIL NIL) 4 NIL NIL NIL NIL) ("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "QUOTED-PRINTABLE" 21 0 NIL NIL NIL NIL) "MIXED" ("BOUNDARY" "----mailcomposer-?=_1-1328088797399") NIL NIL NIL))\r\n'
|
'\n* 3 FETCH (BODYSTRUCTURE (("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 107 (NIL "" ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "<test1>" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 14 0 NIL NIL NIL NIL) 5 NIL NIL NIL NIL)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 85 (NIL "" ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL NIL NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 14 0 NIL NIL NIL NIL) 4 NIL NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "QUOTED-PRINTABLE" 21 0 NIL NIL NIL NIL) "MIXED" ("BOUNDARY" "----mailcomposer-?=_1-1328088797399") NIL NIL NIL))\r\n'
|
||||||
) >= 0
|
) >= 0
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
expect(/^T3 OK/m.test(resp)).to.be.true;
|
expect(/^T3 OK/m.test(resp)).to.be.true;
|
||||||
|
|
16
package.json
16
package.json
|
@ -15,18 +15,18 @@
|
||||||
"author": "Andris Reinman",
|
"author": "Andris Reinman",
|
||||||
"license": "EUPL-1.1+",
|
"license": "EUPL-1.1+",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ajv": "6.7.0",
|
"ajv": "6.8.1",
|
||||||
"apidoc": "0.17.7",
|
"apidoc": "0.17.7",
|
||||||
"browserbox": "0.9.1",
|
"browserbox": "0.9.1",
|
||||||
"chai": "4.2.0",
|
"chai": "4.2.0",
|
||||||
"eslint": "5.12.1",
|
"eslint": "5.13.0",
|
||||||
"eslint-config-nodemailer": "1.2.0",
|
"eslint-config-nodemailer": "1.2.0",
|
||||||
"eslint-config-prettier": "3.6.0",
|
"eslint-config-prettier": "4.0.0",
|
||||||
"grunt": "1.0.3",
|
"grunt": "1.0.3",
|
||||||
"grunt-cli": "1.3.2",
|
"grunt-cli": "1.3.2",
|
||||||
"grunt-eslint": "21.0.0",
|
"grunt-eslint": "21.0.0",
|
||||||
"grunt-mocha-test": "0.13.3",
|
"grunt-mocha-test": "0.13.3",
|
||||||
"grunt-shell-spawn": "0.3.10",
|
"grunt-shell-spawn": "0.4.0",
|
||||||
"grunt-wait": "0.3.0",
|
"grunt-wait": "0.3.0",
|
||||||
"icedfrisby": "1.5.0",
|
"icedfrisby": "1.5.0",
|
||||||
"mailparser": "2.4.3",
|
"mailparser": "2.4.3",
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
"humanname": "0.2.2",
|
"humanname": "0.2.2",
|
||||||
"iconv-lite": "0.4.24",
|
"iconv-lite": "0.4.24",
|
||||||
"ioredfour": "1.0.2-ioredis-02",
|
"ioredfour": "1.0.2-ioredis-02",
|
||||||
"ioredis": "4.5.1",
|
"ioredis": "4.6.2",
|
||||||
"isemail": "3.2.0",
|
"isemail": "3.2.0",
|
||||||
"joi": "14.3.1",
|
"joi": "14.3.1",
|
||||||
"js-yaml": "3.12.1",
|
"js-yaml": "3.12.1",
|
||||||
|
@ -58,14 +58,14 @@
|
||||||
"mongo-cursor-pagination": "7.1.0",
|
"mongo-cursor-pagination": "7.1.0",
|
||||||
"mongodb": "3.1.13",
|
"mongodb": "3.1.13",
|
||||||
"mongodb-extended-json": "1.10.1",
|
"mongodb-extended-json": "1.10.1",
|
||||||
"node-forge": "0.7.6",
|
"node-forge": "0.8.0",
|
||||||
"nodemailer": "5.1.1",
|
"nodemailer": "5.1.1",
|
||||||
"npmlog": "4.1.2",
|
"npmlog": "4.1.2",
|
||||||
"openpgp": "4.4.6",
|
"openpgp": "4.4.6",
|
||||||
"pem": "1.13.2",
|
"pem": "1.14.1",
|
||||||
"pwnedpasswords": "1.0.4",
|
"pwnedpasswords": "1.0.4",
|
||||||
"qrcode": "1.3.3",
|
"qrcode": "1.3.3",
|
||||||
"restify": "7.6.0",
|
"restify": "7.7.0",
|
||||||
"restify-logger": "2.0.1",
|
"restify-logger": "2.0.1",
|
||||||
"seq-index": "1.1.0",
|
"seq-index": "1.1.0",
|
||||||
"smtp-server": "3.5.0",
|
"smtp-server": "3.5.0",
|
||||||
|
|
Loading…
Reference in a new issue