mailparser 3.1.0 → 3.3.2
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 +10 -6
- 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', () => {
|
|
@@ -311,7 +314,7 @@ class MailParser extends Transform {
|
|
|
311
314
|
});
|
|
312
315
|
break;
|
|
313
316
|
case 'date':
|
|
314
|
-
value =
|
|
317
|
+
value = anyDateParser.fromString(value);
|
|
315
318
|
if (isNaN(value)) {
|
|
316
319
|
// date parsing failed :S
|
|
317
320
|
value = new Date();
|
|
@@ -561,13 +564,13 @@ class MailParser extends Transform {
|
|
|
561
564
|
disposition = 'attachment';
|
|
562
565
|
}
|
|
563
566
|
|
|
564
|
-
if (!disposition && !
|
|
567
|
+
if (!disposition && !this.textTypes.includes(contentType)) {
|
|
565
568
|
newNode.disposition = 'attachment';
|
|
566
569
|
} else {
|
|
567
570
|
newNode.disposition = disposition || 'inline';
|
|
568
571
|
}
|
|
569
572
|
|
|
570
|
-
newNode.isAttachment = !
|
|
573
|
+
newNode.isAttachment = !this.textTypes.includes(contentType) || newNode.disposition !== 'inline';
|
|
571
574
|
|
|
572
575
|
newNode.encoding = ['quoted-printable', 'base64'].includes(encoding) ? encoding : 'binary';
|
|
573
576
|
|
|
@@ -715,7 +718,7 @@ class MailParser extends Transform {
|
|
|
715
718
|
if (!alternative && this.hasHtml) {
|
|
716
719
|
html.push(this.textToHtml(node.textContent));
|
|
717
720
|
}
|
|
718
|
-
} else if (node.contentType === 'message/delivery-status') {
|
|
721
|
+
} else if (node.contentType === 'message/delivery-status' && !this.options.keepDeliveryStatus) {
|
|
719
722
|
text.push(node.textContent);
|
|
720
723
|
if (!alternative && this.hasHtml) {
|
|
721
724
|
html.push(this.textToHtml(node.textContent));
|
|
@@ -811,7 +814,8 @@ class MailParser extends Transform {
|
|
|
811
814
|
}
|
|
812
815
|
};
|
|
813
816
|
|
|
814
|
-
let
|
|
817
|
+
let algo = this.options.checksumAlgo || 'md5';
|
|
818
|
+
let hasher = new StreamHash(attachment, algo);
|
|
815
819
|
node.decoder.on('error', err => {
|
|
816
820
|
hasher.emit('error', err);
|
|
817
821
|
});
|
|
@@ -864,7 +868,7 @@ class MailParser extends Transform {
|
|
|
864
868
|
this.hasText = true;
|
|
865
869
|
} else if (node.contentType === 'text/html') {
|
|
866
870
|
this.hasHtml = true;
|
|
867
|
-
} else if (node.contentType === 'message/delivery-status') {
|
|
871
|
+
} else if (node.contentType === 'message/delivery-status' && !this.options.keepDeliveryStatus) {
|
|
868
872
|
this.hasText = true;
|
|
869
873
|
}
|
|
870
874
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mailparser",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.2",
|
|
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
25
|
"linkify-it": "3.0.2",
|
|
25
|
-
"mailsplit": "5.0
|
|
26
|
-
"nodemailer": "6.
|
|
27
|
-
"tlds": "1.
|
|
26
|
+
"mailsplit": "5.2.0",
|
|
27
|
+
"nodemailer": "6.6.5",
|
|
28
|
+
"tlds": "1.222.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"ajv": "
|
|
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": "
|
|
34
|
-
"grunt": "1.
|
|
35
|
-
"grunt-cli": "1.3
|
|
36
|
-
"grunt-contrib-nodeunit": "
|
|
34
|
+
"eslint-config-prettier": "8.3.0",
|
|
35
|
+
"grunt": "1.4.1",
|
|
36
|
+
"grunt-cli": "1.4.3",
|
|
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": {
|