Skip to content

Commit e437f1d

Browse files
committed
v3.4.0
1 parent aa9deb1 commit e437f1d

File tree

4 files changed

+24
-29
lines changed

4 files changed

+24
-29
lines changed

examples/simple.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const util = require('util');
66
const fs = require('fs');
77
const simpleParser = require('../lib/simple-parser.js');
88

9-
let input = fs.createReadStream(__dirname + '/simple.eml');
9+
let input = fs.createReadStream(process.argv[2] || __dirname + '/simple.eml');
1010

1111
simpleParser(input)
1212
.then(mail => {

lib/mail-parser.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const he = require('he');
1414
const linkify = require('linkify-it')();
1515
const tlds = require('tlds');
1616
const encodingJapanese = require('encoding-japanese');
17-
const anyDateParser = require('any-date-parser');
1817

1918
linkify
2019
.tlds(tlds) // Reload with full tlds list
@@ -316,11 +315,8 @@ class MailParser extends Transform {
316315
case 'date': {
317316
let dateValue = new Date(value);
318317
if (isNaN(dateValue)) {
319-
dateValue = anyDateParser.fromString(value);
320-
if (isNaN(dateValue)) {
321-
// date parsing failed :S
322-
dateValue = new Date();
323-
}
318+
// date parsing failed :S
319+
dateValue = new Date();
324320
}
325321
value = dateValue;
326322
break;

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mailparser",
3-
"version": "3.3.3",
3+
"version": "3.4.0",
44
"description": "Parse e-mails",
55
"main": "index.js",
66
"scripts": {
@@ -16,25 +16,24 @@
1616
],
1717
"license": "MIT",
1818
"dependencies": {
19-
"any-date-parser": "1.5.1",
2019
"encoding-japanese": "1.0.30",
2120
"he": "1.2.0",
2221
"html-to-text": "8.0.0",
2322
"iconv-lite": "0.6.3",
2423
"libmime": "5.0.0",
2524
"linkify-it": "3.0.3",
26-
"mailsplit": "5.2.0",
27-
"nodemailer": "6.6.5",
28-
"tlds": "1.222.0"
25+
"mailsplit": "5.3.1",
26+
"nodemailer": "6.7.0",
27+
"tlds": "1.224.0"
2928
},
3029
"devDependencies": {
3130
"ajv": "8.6.3",
32-
"eslint": "7.32.0",
31+
"eslint": "8.0.0",
3332
"eslint-config-nodemailer": "1.2.0",
3433
"eslint-config-prettier": "8.3.0",
3534
"grunt": "1.4.1",
3635
"grunt-cli": "1.4.3",
37-
"grunt-contrib-nodeunit": "3.0.0",
36+
"grunt-contrib-nodeunit": "4.0.0",
3837
"grunt-eslint": "23.0.0",
3938
"iconv": "3.0.1",
4039
"random-message": "1.1.0"

test/simple-parser-test.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ test`
151151
test.done();
152152
});
153153
};
154-
154+
/*
155155
module.exports['Parse invalid date'] = test => {
156156
let source = Buffer.from(
157157
`Date: Tue, 06 Jul 2021 19:21:59 CEST
@@ -169,24 +169,24 @@ test`
169169
test.done();
170170
});
171171
};
172-
172+
*/
173173
const RFC_2822_date = {
174-
'01 Apr 2013 20:18:36 -0500' : '2013-04-02T01:18:36.000Z',
175-
' 01/03/2006' : '2006-01-03T08:00:00.000Z',
176-
'03/11/2014 11:44 AM (GMT-06:00)' : '2014-03-11T18:44:00.000Z',
174+
// commented cases where new Date(val) uses local timezone
175+
'01 Apr 2013 20:18:36 -0500': '2013-04-02T01:18:36.000Z',
176+
//' 01/03/2006': '2006-01-03T08:00:00.000Z',
177+
//'03/11/2014 11:44 AM (GMT-06:00)': '2014-03-11T18:44:00.000Z',
177178
// '2008-10-23, 1:52PM CDT' : '2008-10-23T13:42:00.000Z',
178-
'21 Jan 2013 13:03:51 -0600' : '2013-01-21T19:03:51.000Z',
179-
'4 December 2005' : '2005-12-04T08:00:00.000Z',
180-
'Fri, 02 Dec 2011 09:27:26 -0600' : '2011-12-02T15:27:26.000Z',
179+
'21 Jan 2013 13:03:51 -0600': '2013-01-21T19:03:51.000Z',
180+
//'4 December 2005': '2005-12-04T08:00:00.000Z',
181+
'Fri, 02 Dec 2011 09:27:26 -0600': '2011-12-02T15:27:26.000Z',
181182
'Fri, 07 Mar 2008 02:35:23 -0800 (PST)': '2008-03-07T10:35:23.000Z',
182-
'Fri, 07 Mar 2014 11:01:40 UTC' : '2014-03-07T11:01:40.000Z',
183-
'January 6, 2009 4:44:14 PM CST' : '2009-01-06T22:44:14.000Z',
184-
'Sun, 8 Jan 2017 20:37:44 +0200' : '2017-01-08T18:37:44.000Z',
185-
}
183+
'Fri, 07 Mar 2014 11:01:40 UTC': '2014-03-07T11:01:40.000Z',
184+
'January 6, 2009 4:44:14 PM CST': '2009-01-06T22:44:14.000Z',
185+
'Sun, 8 Jan 2017 20:37:44 +0200': '2017-01-08T18:37:44.000Z'
186+
};
186187

187188
for (const d in RFC_2822_date) {
188189
module.exports[`Parses email date: ${d}`] = test => {
189-
190190
simpleParser(Buffer.from(`Date: ${d}\r\nSubject: test\r\n\r\ntest`), {}, (err, mail) => {
191191
test.ifError(err);
192192
test.ok(mail);
@@ -195,5 +195,5 @@ for (const d in RFC_2822_date) {
195195

196196
test.done();
197197
});
198-
}
199-
};
198+
};
199+
}

0 commit comments

Comments
 (0)