diff --git a/imap-core/lib/indexer/body-structure.js b/imap-core/lib/indexer/body-structure.js index 26db9ac6..4b7110b1 100644 --- a/imap-core/lib/indexer/body-structure.js +++ b/imap-core/lib/indexer/body-structure.js @@ -38,7 +38,7 @@ class BodyStructure { case 'text': return this.processTextNode(node, options); case 'message': - if (node.parsedHeader['content-type'].subtype === 'rfc822' && !/attachment/i.test(node.parsedHeader['content-disposition'])) { + if (node.parsedHeader['content-type'].subtype === 'rfc822') { if (!options.attachmentRFC822) { return this.processRFC822Node(node, options); } diff --git a/imap-core/lib/indexer/parse-mime-tree.js b/imap-core/lib/indexer/parse-mime-tree.js index 1e52483f..24afb44a 100644 --- a/imap-core/lib/indexer/parse-mime-tree.js +++ b/imap-core/lib/indexer/parse-mime-tree.js @@ -107,8 +107,22 @@ class MIMEParser { * from the tree (circular references prohibit conversion to JSON) */ finalizeTree() { + + if (this._node.state === 'header') { + this.processNodeHeader(); + this.processContentType(); + } + + if (this.tree.parsedHeader && this.tree.parsedHeader['content-type'].value === 'message/rfc822') { + this.tree.message = parse(this.tree.body.join('')); + } + let walker = node => { if (node.body) { + if (node.parentNode === this.tree && node.parsedHeader['content-type'].value === 'message/rfc822') { + node.message = parse(node.body.join('')); + } + node.lineCount = node.body.length; node.body = Buffer.from( node.body.join('').