do not store multipart bodies or zero length bodies as attachments

This commit is contained in:
Andris Reinman 2017-04-06 16:30:23 +03:00
parent c9b9442de6
commit 18d4c34f70

View file

@ -302,6 +302,7 @@ class Indexer {
let disposition = (parsedDisposition && parsedDisposition.value || '').toLowerCase().trim() || false;
let isInlineText = false;
let isMultipart = contentType.split('/')[0] === 'multipart';
// If the current node is HTML or Plaintext then allow larger content included in the mime tree
// Also decode text/html value
@ -352,7 +353,7 @@ class Indexer {
}
// remove attachments and very large text nodes from the mime tree
if (node.body && (!isInlineText || node.size > 300 * 1024)) {
if (!isMultipart && node.body && node.body.length && (!isInlineText || node.size > 300 * 1024)) {
let attachmentId = new ObjectID();
let fileName = (node.parsedHeader['content-disposition'] && node.parsedHeader['content-disposition'].params && node.parsedHeader['content-disposition'].params.filename) || (node.parsedHeader['content-type'] && node.parsedHeader['content-type'].params && node.parsedHeader['content-type'].params.name) || false;
@ -393,7 +394,7 @@ class Indexer {
});
// do not include text content, multipart elements and embedded messages in the attachment list
if (!isInlineText && contentType.split('/')[0] !== 'multipart' && !(contentType === 'message/rfc822' && (!disposition || disposition === 'inline'))) {
if (!isInlineText && !(contentType === 'message/rfc822' && (!disposition || disposition === 'inline'))) {
// list in the attachments array
response.attachments.push({
id: attachmentId,