email-forward-parser 1.0.19 → 1.0.22
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/lib/parser.js +15 -21
- package/package.json +1 -1
package/lib/parser.js
CHANGED
|
@@ -130,7 +130,7 @@ var REGEXES = {
|
|
|
130
130
|
],
|
|
131
131
|
|
|
132
132
|
original_subject : [
|
|
133
|
-
|
|
133
|
+
/^\*?Subject\s?:\*?(.+)/im, // Apple Mail (en), Gmail (all locales), Outlook Live / 365 (all locales), New Outlook 2019 (en), Thunderbird (da, en), Missive (en)
|
|
134
134
|
/^Předmět\s?:(.+)/im, // Apple Mail (cs), New Outlook 2019 (cs), Thunderbird (cs)
|
|
135
135
|
/^Emne\s?:(.+)/im, // Apple Mail (da, no), New Outlook 2019 (da), Thunderbird (no)
|
|
136
136
|
/^Betreff\s?:(.+)/im, // Apple Mail (de), New Outlook 2019 (de), Thunderbird (de)
|
|
@@ -172,7 +172,7 @@ var REGEXES = {
|
|
|
172
172
|
],
|
|
173
173
|
|
|
174
174
|
original_from : [
|
|
175
|
-
/^(
|
|
175
|
+
/^(\*?\s*From\s?:\*?(.+))$/m, // Apple Mail (en), Outlook Live / 365 (all locales), New Outlook 2019 (en), Thunderbird (da, en), Missive (en)
|
|
176
176
|
/^(\s*Od\s?:(.+))$/m, // Apple Mail (cs, pl, sk), Gmail (cs, pl, sk), New Outlook 2019 (cs, pl, sk), Thunderbird (cs, sk)
|
|
177
177
|
/^(\s*Fra\s?:(.+))$/m, // Apple Mail (da, no), Gmail (da, no), New Outlook 2019 (da), Thunderbird (no)
|
|
178
178
|
/^(\s*Von\s?:(.+))$/m, // Apple Mail (de), Gmail (de), New Outlook 2019 (de), Thunderbird (de)
|
|
@@ -215,7 +215,7 @@ var REGEXES = {
|
|
|
215
215
|
],
|
|
216
216
|
|
|
217
217
|
original_to : [
|
|
218
|
-
|
|
218
|
+
/^\*?\s*To\s?:\*?(.+)$/m, // Apple Mail (en), Gmail (all locales), Outlook Live / 365 (all locales), Thunderbird (da, en), Missive (en)
|
|
219
219
|
/^\s*Komu\s?:(.+)$/m, // Apple Mail (cs), New Outlook 2019 (cs, sk), Thunderbird (cs)
|
|
220
220
|
/^\s*Til\s?:(.+)$/m, // Apple Mail (da, no), New Outlook 2019 (da), Thunderbird (no)
|
|
221
221
|
/^\s*An\s?:(.+)$/m, // Apple Mail (de), New Outlook 2019 (de), Thunderbird (de)
|
|
@@ -278,7 +278,7 @@ var REGEXES = {
|
|
|
278
278
|
],
|
|
279
279
|
|
|
280
280
|
original_cc : [
|
|
281
|
-
|
|
281
|
+
/^\*?\s*Cc\s?:\*?(.+)$/m, // Apple Mail (en, da, es, fr, hr, it, pt, pt-br, ro, sk), Gmail (all locales), Outlook Live / 365 (all locales), New Outlook 2019 (da, de, en, fr, it, pt-br), Missive (en)
|
|
282
282
|
/^\s*CC\s?:(.+)$/m, // New Outlook 2019 (es, nl, pt), Thunderbird (da, en, es, fi, hr, hu, it, nl, no, pt, pt-br, ro, tr, uk)
|
|
283
283
|
/^\s*Kopie\s?:(.+)$/m, // Apple Mail (cs, de, nl), New Outlook 2019 (cs), Thunderbird (cs)
|
|
284
284
|
/^\s*Kopio\s?:(.+)$/m, // Apple Mail (fi), New Outlook 2019 (es)
|
|
@@ -321,7 +321,7 @@ var REGEXES = {
|
|
|
321
321
|
/^\s*Dată\s?:(.+)$/m, // Apple Mail (ro), Thunderbird (ro)
|
|
322
322
|
/^\s*Дата\s?:(.+)$/m, // Apple Mail (ru, uk), New Outlook 2019 (ru), Thunderbird (ru, uk)
|
|
323
323
|
/^\s*Tarih\s?:(.+)$/m, // Apple Mail (tr), Thunderbird (tr)
|
|
324
|
-
|
|
324
|
+
/^\*?\s*Sent\s?:\*?(.+)$/m, // Outlook Live / 365 (all locales)
|
|
325
325
|
/^\s*Päiväys\s?:(.+)$/m // Thunderbird (fi)
|
|
326
326
|
],
|
|
327
327
|
|
|
@@ -354,7 +354,8 @@ var REGEXES = {
|
|
|
354
354
|
/^\"(.+?)\"\s?\n?\s*[\[|<](.+?)[\]|>]/, // ""Walter Sheltan" <walter.sheltan@acme.com>" or ""Walter Sheltan" [walter.sheltan@acme.com]" or ""walter.sheltan@acme.com" <walter.sheltan@acme.com>"
|
|
355
355
|
/^([^,;]+?)\s?\n?\s*[\[|<](.+?)[\]|>]/, // "Walter Sheltan <walter.sheltan@acme.com>" or "Walter Sheltan [walter.sheltan@acme.com]" or "walter.sheltan@acme.com <walter.sheltan@acme.com>"
|
|
356
356
|
/^(.?)\s?\n?\s*[\[|<](.+?)[\]|>]/, // "<walter.sheltan@acme.com>"
|
|
357
|
-
/^([^\s@]+@[^\s@]+\.[^\s@,]+)
|
|
357
|
+
/^([^\s@]+@[^\s@]+\.[^\s@,]+)/, // "walter.sheltan@acme.com"
|
|
358
|
+
/^([^;].+?)\s?\n?\s*[\[|<](.+?)[\]|>]/, // "Walter, Sheltan <walter.sheltan@acme.com>" or "Walter, Sheltan [walter.sheltan@acme.com]"
|
|
358
359
|
]
|
|
359
360
|
};
|
|
360
361
|
|
|
@@ -425,11 +426,12 @@ class Parser {
|
|
|
425
426
|
// attempt it. The `forwarded` boolean gives the confirmation that the \
|
|
426
427
|
// email was indeed forwarded (detected from the Subject part)
|
|
427
428
|
if (forwarded === true) {
|
|
428
|
-
// Second method: split via the Form part (New Outlook 2019
|
|
429
|
+
// Second method: split via the Form part (New Outlook 2019, \
|
|
430
|
+
// Outlook Live / 365)
|
|
429
431
|
_match = loopRegexes(this.__regexes.original_from, _body, "split");
|
|
430
432
|
|
|
431
433
|
if (_match && _match.length > 3) {
|
|
432
|
-
// The From has been detached by `split
|
|
434
|
+
// The From has been detached by the `split` operation, attach it back
|
|
433
435
|
var _email = _match[1] + _match[_match.length - 1];
|
|
434
436
|
|
|
435
437
|
return {
|
|
@@ -566,7 +568,7 @@ class Parser {
|
|
|
566
568
|
var _author = this.__parseMailbox(this.__regexes.original_from, text);
|
|
567
569
|
|
|
568
570
|
// Author found?
|
|
569
|
-
if (_author.address) {
|
|
571
|
+
if ((_author || {}).address) {
|
|
570
572
|
return _author;
|
|
571
573
|
}
|
|
572
574
|
|
|
@@ -634,9 +636,7 @@ class Parser {
|
|
|
634
636
|
);
|
|
635
637
|
|
|
636
638
|
// Recipient(s) found?
|
|
637
|
-
if (Array.isArray(_recipients) &&
|
|
638
|
-
!(_recipients[0].address === null && _recipients[0].name === null)
|
|
639
|
-
) {
|
|
639
|
+
if (Array.isArray(_recipients) && _recipients.length > 0) {
|
|
640
640
|
return _recipients;
|
|
641
641
|
}
|
|
642
642
|
|
|
@@ -690,9 +690,7 @@ class Parser {
|
|
|
690
690
|
);
|
|
691
691
|
|
|
692
692
|
// Recipient(s) found?
|
|
693
|
-
if (Array.isArray(_recipients) &&
|
|
694
|
-
!(_recipients[0].address === null && _recipients[0].name === null)
|
|
695
|
-
) {
|
|
693
|
+
if (Array.isArray(_recipients) && _recipients.length > 0) {
|
|
696
694
|
return _recipients;
|
|
697
695
|
}
|
|
698
696
|
|
|
@@ -805,12 +803,8 @@ class Parser {
|
|
|
805
803
|
}
|
|
806
804
|
}
|
|
807
805
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
name : null
|
|
811
|
-
};
|
|
812
|
-
|
|
813
|
-
return (force_array === true) ? [_mailbox] : _mailbox;
|
|
806
|
+
// No mailbox found
|
|
807
|
+
return (force_array === true) ? [] : null;
|
|
814
808
|
}
|
|
815
809
|
|
|
816
810
|
|