mailparser 3.2.0 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/lib/mail-parser.js +17 -9
- package/package.json +14 -13
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c)
|
|
1
|
+
Copyright (c) 2020 - 2021 Andris Reinman
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
4
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -13,4 +13,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
13
13
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
14
14
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
15
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
|
-
SOFTWARE.
|
|
16
|
+
SOFTWARE.
|
package/lib/mail-parser.js
CHANGED
|
@@ -14,6 +14,7 @@ const he = require('he');
|
|
|
14
14
|
const linkify = require('linkify-it')();
|
|
15
15
|
const tlds = require('tlds');
|
|
16
16
|
const encodingJapanese = require('encoding-japanese');
|
|
17
|
+
const anyDateParser = require('any-date-parser');
|
|
17
18
|
|
|
18
19
|
linkify
|
|
19
20
|
.tlds(tlds) // Reload with full tlds list
|
|
@@ -156,6 +157,8 @@ class MailParser extends Transform {
|
|
|
156
157
|
|
|
157
158
|
this.boundaries = [];
|
|
158
159
|
|
|
160
|
+
this.textTypes = ['text/plain', 'text/html'].concat(!this.options.keepDeliveryStatus ? 'message/delivery-status' : []);
|
|
161
|
+
|
|
159
162
|
this.decoder = this.getDecoder();
|
|
160
163
|
|
|
161
164
|
this.splitter.on('readable', () => {
|
|
@@ -310,13 +313,18 @@ class MailParser extends Transform {
|
|
|
310
313
|
}
|
|
311
314
|
});
|
|
312
315
|
break;
|
|
313
|
-
case 'date':
|
|
314
|
-
|
|
315
|
-
if (isNaN(
|
|
316
|
-
|
|
317
|
-
|
|
316
|
+
case 'date': {
|
|
317
|
+
let dateValue = new Date(value);
|
|
318
|
+
if (isNaN(dateValue)) {
|
|
319
|
+
dateValue = anyDateParser.fromString(value);
|
|
320
|
+
if (isNaN(dateValue)) {
|
|
321
|
+
// date parsing failed :S
|
|
322
|
+
dateValue = new Date();
|
|
323
|
+
}
|
|
318
324
|
}
|
|
325
|
+
value = dateValue;
|
|
319
326
|
break;
|
|
327
|
+
}
|
|
320
328
|
case 'subject':
|
|
321
329
|
try {
|
|
322
330
|
value = this.libmime.decodeWords(value);
|
|
@@ -561,13 +569,13 @@ class MailParser extends Transform {
|
|
|
561
569
|
disposition = 'attachment';
|
|
562
570
|
}
|
|
563
571
|
|
|
564
|
-
if (!disposition && !
|
|
572
|
+
if (!disposition && !this.textTypes.includes(contentType)) {
|
|
565
573
|
newNode.disposition = 'attachment';
|
|
566
574
|
} else {
|
|
567
575
|
newNode.disposition = disposition || 'inline';
|
|
568
576
|
}
|
|
569
577
|
|
|
570
|
-
newNode.isAttachment = !
|
|
578
|
+
newNode.isAttachment = !this.textTypes.includes(contentType) || newNode.disposition !== 'inline';
|
|
571
579
|
|
|
572
580
|
newNode.encoding = ['quoted-printable', 'base64'].includes(encoding) ? encoding : 'binary';
|
|
573
581
|
|
|
@@ -715,7 +723,7 @@ class MailParser extends Transform {
|
|
|
715
723
|
if (!alternative && this.hasHtml) {
|
|
716
724
|
html.push(this.textToHtml(node.textContent));
|
|
717
725
|
}
|
|
718
|
-
} else if (node.contentType === 'message/delivery-status') {
|
|
726
|
+
} else if (node.contentType === 'message/delivery-status' && !this.options.keepDeliveryStatus) {
|
|
719
727
|
text.push(node.textContent);
|
|
720
728
|
if (!alternative && this.hasHtml) {
|
|
721
729
|
html.push(this.textToHtml(node.textContent));
|
|
@@ -865,7 +873,7 @@ class MailParser extends Transform {
|
|
|
865
873
|
this.hasText = true;
|
|
866
874
|
} else if (node.contentType === 'text/html') {
|
|
867
875
|
this.hasHtml = true;
|
|
868
|
-
} else if (node.contentType === 'message/delivery-status') {
|
|
876
|
+
} else if (node.contentType === 'message/delivery-status' && !this.options.keepDeliveryStatus) {
|
|
869
877
|
this.hasText = true;
|
|
870
878
|
}
|
|
871
879
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mailparser",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.3",
|
|
4
4
|
"description": "Parse e-mails",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,26 +16,27 @@
|
|
|
16
16
|
],
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"any-date-parser": "1.5.1",
|
|
19
20
|
"encoding-japanese": "1.0.30",
|
|
20
21
|
"he": "1.2.0",
|
|
21
|
-
"html-to-text": "
|
|
22
|
-
"iconv-lite": "0.6.
|
|
22
|
+
"html-to-text": "8.0.0",
|
|
23
|
+
"iconv-lite": "0.6.3",
|
|
23
24
|
"libmime": "5.0.0",
|
|
24
|
-
"linkify-it": "3.0.
|
|
25
|
-
"mailsplit": "5.0
|
|
26
|
-
"nodemailer": "6.5
|
|
27
|
-
"tlds": "1.
|
|
25
|
+
"linkify-it": "3.0.3",
|
|
26
|
+
"mailsplit": "5.2.0",
|
|
27
|
+
"nodemailer": "6.6.5",
|
|
28
|
+
"tlds": "1.222.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"ajv": "8.
|
|
31
|
-
"eslint": "7.
|
|
31
|
+
"ajv": "8.6.3",
|
|
32
|
+
"eslint": "7.32.0",
|
|
32
33
|
"eslint-config-nodemailer": "1.2.0",
|
|
33
|
-
"eslint-config-prettier": "8.
|
|
34
|
-
"grunt": "1.
|
|
35
|
-
"grunt-cli": "1.4.
|
|
34
|
+
"eslint-config-prettier": "8.3.0",
|
|
35
|
+
"grunt": "1.4.1",
|
|
36
|
+
"grunt-cli": "1.4.3",
|
|
36
37
|
"grunt-contrib-nodeunit": "3.0.0",
|
|
37
38
|
"grunt-eslint": "23.0.0",
|
|
38
|
-
"iconv": "3.0.
|
|
39
|
+
"iconv": "3.0.1",
|
|
39
40
|
"random-message": "1.1.0"
|
|
40
41
|
},
|
|
41
42
|
"repository": {
|