Skip to content

Commit

Permalink
v3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Aug 4, 2021
1 parent 86ad6e9 commit 6de6758
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
10 changes: 6 additions & 4 deletions lib/mail-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ class MailParser extends Transform {

this.boundaries = [];

this.textTypes = ['text/plain', 'text/html'].concat(!this.options.keepDeliveryStatus ? 'message/delivery-status' : []);

this.decoder = this.getDecoder();

this.splitter.on('readable', () => {
Expand Down Expand Up @@ -561,13 +563,13 @@ class MailParser extends Transform {
disposition = 'attachment';
}

if (!disposition && !['text/plain', 'text/html', 'message/delivery-status'].includes(contentType)) {
if (!disposition && !this.textTypes.includes(contentType)) {
newNode.disposition = 'attachment';
} else {
newNode.disposition = disposition || 'inline';
}

newNode.isAttachment = !['text/plain', 'text/html', 'message/delivery-status'].includes(contentType) || newNode.disposition !== 'inline';
newNode.isAttachment = !this.textTypes.includes(contentType) || newNode.disposition !== 'inline';

newNode.encoding = ['quoted-printable', 'base64'].includes(encoding) ? encoding : 'binary';

Expand Down Expand Up @@ -715,7 +717,7 @@ class MailParser extends Transform {
if (!alternative && this.hasHtml) {
html.push(this.textToHtml(node.textContent));
}
} else if (node.contentType === 'message/delivery-status') {
} else if (node.contentType === 'message/delivery-status' && !this.options.keepDeliveryStatus) {
text.push(node.textContent);
if (!alternative && this.hasHtml) {
html.push(this.textToHtml(node.textContent));
Expand Down Expand Up @@ -865,7 +867,7 @@ class MailParser extends Transform {
this.hasText = true;
} else if (node.contentType === 'text/html') {
this.hasHtml = true;
} else if (node.contentType === 'message/delivery-status') {
} else if (node.contentType === 'message/delivery-status' && !this.options.keepDeliveryStatus) {
this.hasText = true;
}

Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mailparser",
"version": "3.2.0",
"version": "3.3.0",
"description": "Parse e-mails",
"main": "index.js",
"scripts": {
Expand All @@ -18,21 +18,21 @@
"dependencies": {
"encoding-japanese": "1.0.30",
"he": "1.2.0",
"html-to-text": "7.0.0",
"iconv-lite": "0.6.2",
"html-to-text": "8.0.0",
"iconv-lite": "0.6.3",
"libmime": "5.0.0",
"linkify-it": "3.0.2",
"mailsplit": "5.0.1",
"nodemailer": "6.6.3",
"tlds": "1.219.0"
"tlds": "1.221.1"
},
"devDependencies": {
"ajv": "8.0.4",
"eslint": "7.23.0",
"ajv": "8.6.2",
"eslint": "7.32.0",
"eslint-config-nodemailer": "1.2.0",
"eslint-config-prettier": "8.1.0",
"grunt": "1.3.0",
"grunt-cli": "1.4.1",
"eslint-config-prettier": "8.3.0",
"grunt": "1.4.1",
"grunt-cli": "1.4.3",
"grunt-contrib-nodeunit": "3.0.0",
"grunt-eslint": "23.0.0",
"iconv": "3.0.0",
Expand Down

0 comments on commit 6de6758

Please sign in to comment.