email-forward-parser 1.8.3 → 1.8.4
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/README.md +2 -14
- package/dist/parser.js +310 -265
- package/dist/utils.d.ts +3 -4
- package/dist/utils.js +1 -42
- package/package.json +3 -13
package/README.md
CHANGED
|
@@ -27,21 +27,9 @@ This library is used at [Crisp](https://crisp.chat/) everyday with around 1 mill
|
|
|
27
27
|
* Supported clients: Apple Mail, Gmail, Outlook Live / 365, Outlook 2013, Outlook 2019, New Outlook 2019, Yahoo Mail, Thunderbird, Missive, HubSpot, IONOS by 1 & 1, MailMate
|
|
28
28
|
* Supported locales: Croatian, Czech, Danish, Dutch, English, French, Finnish, German, Hungarian, Italian, Japanese, Norwegian, Polish, Portuguese (Brazil), Portuguese (Portugal), Romanian, Russian, Slovak, Spanish, Swedish, Turkish, Ukrainian
|
|
29
29
|
|
|
30
|
-
##
|
|
30
|
+
## ReDoS Protection
|
|
31
31
|
|
|
32
|
-
This library
|
|
33
|
-
|
|
34
|
-
RE2 is an optional dependency installed by default. If you encounter native compilation issues or want to exclude it:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
npm uninstall re2
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
After a Node.js upgrade, you may need to rebuild RE2:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
npm rebuild re2
|
|
44
|
-
```
|
|
32
|
+
This library has no native dependency. Its patterns are written to run in linear time on the native JavaScript `RegExp` engine, which protects against [ReDoS](https://en.wikipedia.org/wiki/ReDoS) on crafted emails.
|
|
45
33
|
|
|
46
34
|
## Usage
|
|
47
35
|
|
package/dist/parser.js
CHANGED
|
@@ -8,10 +8,19 @@
|
|
|
8
8
|
* IMPORTS
|
|
9
9
|
***************************************************************************/
|
|
10
10
|
// PROJECT: LIB
|
|
11
|
-
import {
|
|
11
|
+
import { loopRegexes, reconciliateSplitMatch, trimString } from "./utils.js";
|
|
12
12
|
/**************************************************************************
|
|
13
13
|
* CONSTANTS
|
|
14
14
|
***************************************************************************/
|
|
15
|
+
// Patterns must stay linear on backtracking engines: no nested or adjacent unbounded quantifiers
|
|
16
|
+
// Line terminators, and whitespace that is not a line terminator
|
|
17
|
+
const NEWLINES = "\\n\\r\\u2028\\u2029";
|
|
18
|
+
const HS = `[^\\S${NEWLINES}]`;
|
|
19
|
+
// Mailbox brackets (Outlook 2019, Yahoo Mail)
|
|
20
|
+
const OPEN = "[\\[|<]";
|
|
21
|
+
const CLOSE = "[\\]|>]";
|
|
22
|
+
const HU_OPEN = "[\\[|<|(]";
|
|
23
|
+
const HU_CLOSE = "[\\]|>|)]";
|
|
15
24
|
const MAILBOXES_SEPARATORS = [
|
|
16
25
|
",", // Apple Mail, Gmail, New Outlook 2019, Thunderbird
|
|
17
26
|
";" // Outlook Live / 365, Yahoo Mail
|
|
@@ -25,8 +34,85 @@ const LINE_REGEXES = [
|
|
|
25
34
|
"original_cc",
|
|
26
35
|
"original_date"
|
|
27
36
|
];
|
|
37
|
+
/**************************************************************************
|
|
38
|
+
* HELPERS
|
|
39
|
+
***************************************************************************/
|
|
40
|
+
/**
|
|
41
|
+
* Builds a regex from a raw template, so that patterns read like literals
|
|
42
|
+
*/
|
|
43
|
+
function regex(flags = "") {
|
|
44
|
+
return (strings, ...values) => {
|
|
45
|
+
return new RegExp(String.raw(strings, ...values), flags);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const multiline = regex("m");
|
|
49
|
+
/**
|
|
50
|
+
* Any characters up to the first STOP on the line (a single way to split, so no backtracking)
|
|
51
|
+
*/
|
|
52
|
+
function upTo(stop, quantifier = "*") {
|
|
53
|
+
return `(?:(?!${stop}).)${quantifier}`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Lazily, characters matching CHAR or whole whitespace runs (never split, so never retried)
|
|
57
|
+
*/
|
|
58
|
+
function lazyWords(char, whitespace = HS) {
|
|
59
|
+
return `(?:${char}|${whitespace}+(?=\\S))*?`;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Bracketed mailbox address, that cannot span over the next place an address could START
|
|
63
|
+
*/
|
|
64
|
+
function bracketAddress(start = OPEN) {
|
|
65
|
+
return upTo(start, "+");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Unquoted sender name, that cannot span over STOP and ends before whitespace (or is blank)
|
|
69
|
+
*/
|
|
70
|
+
function bareName(stop = null) {
|
|
71
|
+
if (stop === null) {
|
|
72
|
+
return `(?:.*\\S|${HS}+(?=\\S))`;
|
|
73
|
+
}
|
|
74
|
+
return `(?:${upTo(stop)}(?!${stop})\\S|${HS}+(?=\\S))`;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Yahoo Mail "KEYWORD: NAME <EMAIL>" header, where NAME and EMAIL cannot span over KEYWORD
|
|
78
|
+
*/
|
|
79
|
+
function laxFromHeader(keyword) {
|
|
80
|
+
const name = `.${lazyWords(`(?!${keyword}\\s?:)[^\\s\\[|<]`)}`;
|
|
81
|
+
const address = `.${upTo(`${CLOSE}|${keyword}\\s?:`)}`;
|
|
82
|
+
return new RegExp(`(?<!\\s)(\\s*${keyword}\\s?:(${name})\\s*${OPEN}(${address})${CLOSE})`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Removes named capture groups, to detect a separator without extracting its information
|
|
86
|
+
*/
|
|
87
|
+
function withoutGroups(pattern) {
|
|
88
|
+
return new RegExp(pattern.source.replace(/\(\?<\w+>/g, "(?:"), pattern.flags);
|
|
89
|
+
}
|
|
90
|
+
/* eslint-disable max-len */
|
|
91
|
+
/**************************************************************************
|
|
92
|
+
* CONSTANTS
|
|
93
|
+
***************************************************************************/
|
|
94
|
+
const ADDRESS = bracketAddress();
|
|
95
|
+
const QUOTED_ADDRESS = bracketAddress(`"\\s*${OPEN}`);
|
|
96
|
+
const OUTLOOK_2019_SEPARATORS_WITH_INFORMATION = [
|
|
97
|
+
multiline `^\s?Dne\s?(?<date>.+)\,\s?(?<from_name>${bareName(",")})\s*${OPEN}(?<from_address>${ADDRESS})${CLOSE}\s?napsal\(a\)\s?:`, // Outlook 2019 (cz)
|
|
98
|
+
multiline `^\s?D.\s?(?<date>.+)\s?skrev\s?\"(?<from_name>${upTo("skrev\\s?\"", "+")})\"\s*${OPEN}(?<from_address>${QUOTED_ADDRESS})${CLOSE}\s?:`, // Outlook 2019 (da)
|
|
99
|
+
multiline `^\s?Am\s?(?<date>.+)\s?schrieb\s?\"(?<from_name>${upTo("schrieb\\s?\"", "+")})\"\s*${OPEN}(?<from_address>${QUOTED_ADDRESS})${CLOSE}\s?:`, // Outlook 2019 (de)
|
|
100
|
+
multiline `^\s?On\s?(?<date>.+)\,\s?\"(?<from_name>${upTo(",\\s?\"", "+")})\"\s*${OPEN}(?<from_address>${QUOTED_ADDRESS})${CLOSE}\s?wrote\s?:`, // Outlook 2019 (en)
|
|
101
|
+
multiline `^\s?El\s?(?<date>.+)\,\s?\"(?<from_name>${upTo(",\\s?\"", "+")})\"\s*${OPEN}(?<from_address>${QUOTED_ADDRESS})${CLOSE}\s?escribió\s?:`, // Outlook 2019 (es)
|
|
102
|
+
multiline `^\s?Le\s?(?<date>.+)\,\s?«(?<from_name>${upTo(",\\s?«", "+")})»\s*${OPEN}(?<from_address>${bracketAddress(`»\\s*${OPEN}`)})${CLOSE}\s?a écrit\s?:`, // Outlook 2019 (fr)
|
|
103
|
+
multiline `^\s?(?<from_name>${bareName()})\s*${OPEN}(?<from_address>${ADDRESS})${CLOSE}\s?kirjoitti\s?(?<date>${upTo(`${CLOSE}\\s?kirjoitti`, "+")})\s?:`, // Outlook 2019 (fi)
|
|
104
|
+
multiline `^\s?(?<date>.+)\s?időpontban\s?(?<from_name>${bareName("időpontban")})\s*${HU_OPEN}(?<from_address>${bracketAddress(HU_OPEN)})${HU_CLOSE}\s?ezt írta\s?:`, // Outlook 2019 (hu)
|
|
105
|
+
multiline `^\s?Il giorno\s?(?<date>.+)\s?\"(?<from_name>${upTo("\"", "+")})\"\s*${OPEN}(?<from_address>${QUOTED_ADDRESS})${CLOSE}\s?ha scritto\s?:`, // Outlook 2019 (it)
|
|
106
|
+
multiline `^\s?Op\s?(?<date>.+)\s?heeft\s?(?<from_name>${bareName("heeft")})\s*${OPEN}(?<from_address>${ADDRESS})${CLOSE}\s?geschreven\s?:`, // Outlook 2019 (nl)
|
|
107
|
+
multiline `^\s?(?<from_name>${bareName()})\s*${OPEN}(?<from_address>${ADDRESS})${CLOSE}\s?skrev følgende den\s?(?<date>${upTo(`${CLOSE}\\s?skrev følgende den`, "+")})\s?:`, // Outlook 2019 (no)
|
|
108
|
+
multiline `^\s?Dnia\s?(?<date>.+)\s?„(?<from_name>${upTo("„", "+")})”\s*${OPEN}(?<from_address>${bracketAddress(`”\\s*${OPEN}`)})${CLOSE}\s?napisał\s?:`, // Outlook 2019 (pl)
|
|
109
|
+
multiline `^\s?Em\s?(?<date>.+)\,\s?\"(?<from_name>${upTo(",\\s?\"", "+")})\"\s*${OPEN}(?<from_address>${QUOTED_ADDRESS})${CLOSE}\s?escreveu\s?:`, // Outlook 2019 (pt)
|
|
110
|
+
multiline `^\s?(?<date>.+)\s?пользователь\s?\"(?<from_name>${upTo("пользователь\\s?\"", "+")})\"\s*${OPEN}(?<from_address>${QUOTED_ADDRESS})${CLOSE}\s?написал\s?:`, // Outlook 2019 (ru)
|
|
111
|
+
multiline `^\s?(?<date>.+)\s?používateľ\s?(?<from_name>${bareName("používateľ")})\s*\(${OPEN}(?<from_address>${bracketAddress(`\\(${OPEN}`)})${CLOSE}\)\s?napísal\s?:`, // Outlook 2019 (sk)
|
|
112
|
+
multiline `^\s?Den\s?(?<date>.+)\s?skrev\s?\"(?<from_name>${upTo("skrev\\s?\"", "+")})\"\s*${OPEN}(?<from_address>${QUOTED_ADDRESS})${CLOSE}\s?följande\s?:`, // Outlook 2019 (sv)
|
|
113
|
+
multiline `^\s?\"(?<from_name>.+)\"\s*${OPEN}(?<from_address>${QUOTED_ADDRESS})${CLOSE}\,\s?(?<date>${upTo(`${CLOSE},`, "+")})\s?tarihinde şunu yazdı\s?:` // Outlook 2019 (tr)
|
|
114
|
+
];
|
|
28
115
|
const REGEXES = {
|
|
29
|
-
/* eslint-disable max-len */
|
|
30
116
|
quote_line_break: /^(>+)\s?$/gm, // Apple Mail, Missive
|
|
31
117
|
quote: /^(>+)\s?/gm, // Apple Mail
|
|
32
118
|
four_spaces: /^(\ {4})\s?/gm, // Outlook 2019
|
|
@@ -53,100 +139,66 @@ const REGEXES = {
|
|
|
53
139
|
/^Fwd:(.*)/m // Gmail (all locales), Thunderbird (all locales), Missive (en), MailMate (en)
|
|
54
140
|
],
|
|
55
141
|
separator: [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
142
|
+
multiline `^>?${HS}*Begin forwarded message\s?:`, // Apple Mail (en)
|
|
143
|
+
multiline `^>?${HS}*Začátek přeposílané zprávy\s?:`, // Apple Mail (cs)
|
|
144
|
+
multiline `^>?${HS}*Start på videresendt besked\s?:`, // Apple Mail (da)
|
|
145
|
+
multiline `^>?${HS}*Anfang der weitergeleiteten Nachricht\s?:`, // Apple Mail (de)
|
|
146
|
+
multiline `^>?${HS}*Inicio del mensaje reenviado\s?:`, // Apple Mail (es)
|
|
147
|
+
multiline `^>?${HS}*Välitetty viesti alkaa\s?:`, // Apple Mail (fi)
|
|
148
|
+
multiline `^>?${HS}*Début du message réexpédié\s?:`, // Apple Mail (fr)
|
|
149
|
+
multiline `^>?${HS}*Début du message transféré\s?:`, // Apple Mail iOS (fr)
|
|
150
|
+
multiline `^>?${HS}*Započni proslijeđenu poruku\s?:`, // Apple Mail (hr)
|
|
151
|
+
multiline `^>?${HS}*Továbbított levél kezdete\s?:`, // Apple Mail (hu)
|
|
152
|
+
multiline `^>?${HS}*Inizio messaggio inoltrato\s?:`, // Apple Mail (it)
|
|
153
|
+
multiline `^>?${HS}*Begin doorgestuurd bericht\s?:`, // Apple Mail (nl)
|
|
154
|
+
multiline `^>?${HS}*Videresendt melding\s?:`, // Apple Mail (no)
|
|
155
|
+
multiline `^>?${HS}*Początek przekazywanej wiadomości\s?:`, // Apple Mail (pl)
|
|
156
|
+
multiline `^>?${HS}*Início da mensagem reencaminhada\s?:`, // Apple Mail (pt)
|
|
157
|
+
multiline `^>?${HS}*Início da mensagem encaminhada\s?:`, // Apple Mail (pt-br)
|
|
158
|
+
multiline `^>?${HS}*Începe mesajul redirecționat\s?:`, // Apple Mail (ro)
|
|
159
|
+
multiline `^>?${HS}*Начало переадресованного сообщения\s?:`, // Apple Mail (ro)
|
|
160
|
+
multiline `^>?${HS}*Začiatok preposlanej správy\s?:`, // Apple Mail (sk)
|
|
161
|
+
multiline `^>?${HS}*Vidarebefordrat mejl\s?:`, // Apple Mail (sv)
|
|
162
|
+
multiline `^>?${HS}*İleti başlangıcı\s?:`, // Apple Mail (tr)
|
|
163
|
+
multiline `^>?${HS}*Початок листа, що пересилається\s?:`, // Apple Mail (uk)
|
|
164
|
+
multiline `^${HS}*-{8,10}\s*Forwarded message\s*-{8,10}\s*`, // Gmail (all locales), Missive (en), HubSpot (en)
|
|
165
|
+
multiline `^${HS}*_{32}\s*$`, // Outlook Live / 365 (all locales)
|
|
80
166
|
/^\s?Forwarded message:/m, // Mailmate
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
/^\s*-{5} Preposlaná správa -{5}\s*/m, // Yahoo Mail (sk)
|
|
115
|
-
/^\s*-{5,10} Vidarebefordrat meddelande -{5,10}\s*/m, // Yahoo Mail (sv), Thunderbird (sv), HubSpot (sv)
|
|
116
|
-
/^\s*-{5} İletilmiş Mesaj -{5}\s*/m, // Yahoo Mail (tr)
|
|
117
|
-
/^\s*-{5} Перенаправлене повідомлення -{5}\s*/m, // Yahoo Mail (uk)
|
|
118
|
-
/^\s*-{8} Välitetty viesti \/ Fwd.Msg -{8}\s*/m, // Thunderbird (fi)
|
|
119
|
-
/^\s*-{8,10} Message transféré -{8,10}\s*/m, // Thunderbird (fr), HubSpot (fr)
|
|
120
|
-
/^\s*-{8} Proslijeđena poruka -{8}\s*/m, // Thunderbird (hr)
|
|
121
|
-
/^\s*-{8} Messaggio Inoltrato -{8}\s*/m, // Thunderbird (it)
|
|
122
|
-
/^\s*-{3} Treść przekazanej wiadomości -{3}\s*/m, // Thunderbird (pl)
|
|
123
|
-
/^\s*-{8} Перенаправленное сообщение -{8}\s*/m, // Thunderbird (ru)
|
|
124
|
-
/^\s*-{8} Preposlaná správa --- Forwarded Message -{8}\s*/m, // Thunderbird (sk)
|
|
125
|
-
/^\s*-{8} İletilen İleti -{8}\s*/m, // Thunderbird (tr)
|
|
126
|
-
/^\s*-{8} Переслане повідомлення -{8}\s*/m, // Thunderbird (uk)
|
|
127
|
-
/^\s*-{9,10} メッセージを転送 -{9,10}\s*/m, // HubSpot (ja)
|
|
128
|
-
/^\s*-{9,10} Wiadomość przesłana dalej -{9,10}\s*/m, // HubSpot (pl)
|
|
129
|
-
/^>?\s*-{10} Original Message -{10}\s*/m // IONOS by 1 & 1 (en)
|
|
130
|
-
],
|
|
131
|
-
separator_with_information: [
|
|
132
|
-
/^\s?Dne\s?(?<date>.+)\,\s?(?<from_name>.+)\s*[\[|<](?<from_address>.+)[\]|>]\s?napsal\(a\)\s?:/m, // Outlook 2019 (cz)
|
|
133
|
-
/^\s?D.\s?(?<date>.+)\s?skrev\s?\"(?<from_name>.+)\"\s*[\[|<](?<from_address>.+)[\]|>]\s?:/m, // Outlook 2019 (da)
|
|
134
|
-
/^\s?Am\s?(?<date>.+)\s?schrieb\s?\"(?<from_name>.+)\"\s*[\[|<](?<from_address>.+)[\]|>]\s?:/m, // Outlook 2019 (de)
|
|
135
|
-
/^\s?On\s?(?<date>.+)\,\s?\"(?<from_name>.+)\"\s*[\[|<](?<from_address>.+)[\]|>]\s?wrote\s?:/m, // Outlook 2019 (en)
|
|
136
|
-
/^\s?El\s?(?<date>.+)\,\s?\"(?<from_name>.+)\"\s*[\[|<](?<from_address>.+)[\]|>]\s?escribió\s?:/m, // Outlook 2019 (es)
|
|
137
|
-
/^\s?Le\s?(?<date>.+)\,\s?«(?<from_name>.+)»\s*[\[|<](?<from_address>.+)[\]|>]\s?a écrit\s?:/m, // Outlook 2019 (fr)
|
|
138
|
-
/^\s?(?<from_name>.+)\s*[\[|<](?<from_address>.+)[\]|>]\s?kirjoitti\s?(?<date>.+)\s?:/m, // Outlook 2019 (fi)
|
|
139
|
-
/^\s?(?<date>.+)\s?időpontban\s?(?<from_name>.+)\s*[\[|<|(](?<from_address>.+)[\]|>|)]\s?ezt írta\s?:/m, // Outlook 2019 (hu)
|
|
140
|
-
/^\s?Il giorno\s?(?<date>.+)\s?\"(?<from_name>.+)\"\s*[\[|<](?<from_address>.+)[\]|>]\s?ha scritto\s?:/m, // Outlook 2019 (it)
|
|
141
|
-
/^\s?Op\s?(?<date>.+)\s?heeft\s?(?<from_name>.+)\s*[\[|<](?<from_address>.+)[\]|>]\s?geschreven\s?:/m, // Outlook 2019 (nl)
|
|
142
|
-
/^\s?(?<from_name>.+)\s*[\[|<](?<from_address>.+)[\]|>]\s?skrev følgende den\s?(?<date>.+)\s?:/m, // Outlook 2019 (no)
|
|
143
|
-
/^\s?Dnia\s?(?<date>.+)\s?„(?<from_name>.+)”\s*[\[|<](?<from_address>.+)[\]|>]\s?napisał\s?:/m, // Outlook 2019 (pl)
|
|
144
|
-
/^\s?Em\s?(?<date>.+)\,\s?\"(?<from_name>.+)\"\s*[\[|<](?<from_address>.+)[\]|>]\s?escreveu\s?:/m, // Outlook 2019 (pt)
|
|
145
|
-
/^\s?(?<date>.+)\s?пользователь\s?\"(?<from_name>.+)\"\s*[\[|<](?<from_address>.+)[\]|>]\s?написал\s?:/m, // Outlook 2019 (ru)
|
|
146
|
-
/^\s?(?<date>.+)\s?používateľ\s?(?<from_name>.+)\s*\([\[|<](?<from_address>.+)[\]|>]\)\s?napísal\s?:/m, // Outlook 2019 (sk)
|
|
147
|
-
/^\s?Den\s?(?<date>.+)\s?skrev\s?\"(?<from_name>.+)\"\s*[\[|<](?<from_address>.+)[\]|>]\s?följande\s?:/m, // Outlook 2019 (sv)
|
|
148
|
-
/^\s?\"(?<from_name>.+)\"\s*[\[|<](?<from_address>.+)[\]|>]\,\s?(?<date>.+)\s?tarihinde şunu yazdı\s?:/m // Outlook 2019 (tr)
|
|
167
|
+
...OUTLOOK_2019_SEPARATORS_WITH_INFORMATION.map(withoutGroups), // Outlook 2019 (all locales)
|
|
168
|
+
multiline `^${HS}*-{5,8} Přeposlaná zpráva -{5,8}\s*`, // Yahoo Mail (cs), Thunderbird (cs)
|
|
169
|
+
multiline `^${HS}*-{5,8} Videresendt meddelelse -{5,8}\s*`, // Yahoo Mail (da), Thunderbird (da)
|
|
170
|
+
multiline `^${HS}*-{5,10} Weitergeleitete Nachricht -{5,10}\s*`, // Yahoo Mail (de), Thunderbird (de), HubSpot (de)
|
|
171
|
+
multiline `^${HS}*-{5,8} Forwarded Message -{5,8}\s*`, // Yahoo Mail (en), Thunderbird (en)
|
|
172
|
+
multiline `^${HS}*-{5,10} Mensaje reenviado -{5,10}\s*`, // Yahoo Mail (es), Thunderbird (es), HubSpot (es)
|
|
173
|
+
multiline `^${HS}*-{5,10} Edelleenlähetetty viesti -{5,10}\s*`, // Yahoo Mail (fi), HubSpot (fi)
|
|
174
|
+
multiline `^${HS}*-{5} Message transmis -{5}\s*`, // Yahoo Mail (fr)
|
|
175
|
+
multiline `^${HS}*-{5,8} Továbbított üzenet -{5,8}\s*`, // Yahoo Mail (hu), Thunderbird (hu)
|
|
176
|
+
multiline `^${HS}*-{5,10} Messaggio inoltrato -{5,10}\s*`, // Yahoo Mail (it), HubSpot (it)
|
|
177
|
+
multiline `^${HS}*-{5,10} Doorgestuurd bericht -{5,10}\s*`, // Yahoo Mail (nl), Thunderbird (nl), HubSpot (nl)
|
|
178
|
+
multiline `^${HS}*-{5,8} Videresendt melding -{5,8}\s*`, // Yahoo Mail (no), Thunderbird (no)
|
|
179
|
+
multiline `^${HS}*-{5} Przekazana wiadomość -{5}\s*`, // Yahoo Mail (pl)
|
|
180
|
+
multiline `^${HS}*-{5,8} Mensagem reencaminhada -{5,8}\s*`, // Yahoo Mail (pt), Thunderbird (pt)
|
|
181
|
+
multiline `^${HS}*-{5,10} Mensagem encaminhada -{5,10}\s*`, // Yahoo Mail (pt-br), Thunderbird (pt-br), HubSpot (pt-br)
|
|
182
|
+
multiline `^${HS}*-{5,8} Mesaj redirecționat -{5,8}\s*`, // Yahoo Mail (ro)
|
|
183
|
+
multiline `^${HS}*-{5} Пересылаемое сообщение -{5}\s*`, // Yahoo Mail (ru)
|
|
184
|
+
multiline `^${HS}*-{5} Preposlaná správa -{5}\s*`, // Yahoo Mail (sk)
|
|
185
|
+
multiline `^${HS}*-{5,10} Vidarebefordrat meddelande -{5,10}\s*`, // Yahoo Mail (sv), Thunderbird (sv), HubSpot (sv)
|
|
186
|
+
multiline `^${HS}*-{5} İletilmiş Mesaj -{5}\s*`, // Yahoo Mail (tr)
|
|
187
|
+
multiline `^${HS}*-{5} Перенаправлене повідомлення -{5}\s*`, // Yahoo Mail (uk)
|
|
188
|
+
multiline `^${HS}*-{8} Välitetty viesti \/ Fwd.Msg -{8}\s*`, // Thunderbird (fi)
|
|
189
|
+
multiline `^${HS}*-{8,10} Message transféré -{8,10}\s*`, // Thunderbird (fr), HubSpot (fr)
|
|
190
|
+
multiline `^${HS}*-{8} Proslijeđena poruka -{8}\s*`, // Thunderbird (hr)
|
|
191
|
+
multiline `^${HS}*-{8} Messaggio Inoltrato -{8}\s*`, // Thunderbird (it)
|
|
192
|
+
multiline `^${HS}*-{3} Treść przekazanej wiadomości -{3}\s*`, // Thunderbird (pl)
|
|
193
|
+
multiline `^${HS}*-{8} Перенаправленное сообщение -{8}\s*`, // Thunderbird (ru)
|
|
194
|
+
multiline `^${HS}*-{8} Preposlaná správa --- Forwarded Message -{8}\s*`, // Thunderbird (sk)
|
|
195
|
+
multiline `^${HS}*-{8} İletilen İleti -{8}\s*`, // Thunderbird (tr)
|
|
196
|
+
multiline `^${HS}*-{8} Переслане повідомлення -{8}\s*`, // Thunderbird (uk)
|
|
197
|
+
multiline `^${HS}*-{9,10} メッセージを転送 -{9,10}\s*`, // HubSpot (ja)
|
|
198
|
+
multiline `^${HS}*-{9,10} Wiadomość przesłana dalej -{9,10}\s*`, // HubSpot (pl)
|
|
199
|
+
multiline `^>?${HS}*-{10} Original Message -{10}\s*` // IONOS by 1 & 1 (en)
|
|
149
200
|
],
|
|
201
|
+
separator_with_information: OUTLOOK_2019_SEPARATORS_WITH_INFORMATION,
|
|
150
202
|
original_subject: [
|
|
151
203
|
/^\*?Subject\s?:\*?(.+)/im, // Apple Mail (en), Gmail (all locales), Outlook Live / 365 (all locales), New Outlook 2019 (en), Thunderbird (da, en), Missive (en), HubSpot (en)
|
|
152
204
|
/^Předmět\s?:(.+)/im, // Apple Mail (cs), New Outlook 2019 (cs), Thunderbird (cs)
|
|
@@ -189,191 +241,190 @@ const REGEXES = {
|
|
|
189
241
|
/Konu\s?:(.+)/i // Yahoo Mail (tr)
|
|
190
242
|
],
|
|
191
243
|
original_from: [
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
244
|
+
multiline `^(\*?${HS}*From\s?:\*?(.+))$`, // Apple Mail (en), Outlook Live / 365 (all locales), New Outlook 2019 (en), Thunderbird (da, en), Missive (en), HubSpot (en)
|
|
245
|
+
multiline `^(${HS}*Od\s?:(.+))$`, // Apple Mail (cs, pl, sk), Gmail (cs, pl, sk), New Outlook 2019 (cs, pl, sk), Thunderbird (cs, sk), HubSpot (pl)
|
|
246
|
+
multiline `^(${HS}*Fra\s?:(.+))$`, // Apple Mail (da, no), Gmail (da, no), New Outlook 2019 (da), Thunderbird (no)
|
|
247
|
+
multiline `^(${HS}*Von\s?:(.+))$`, // Apple Mail (de), Gmail (de), New Outlook 2019 (de), Thunderbird (de), HubSpot (de)
|
|
248
|
+
multiline `^(${HS}*De\s?:(.+))$`, // Apple Mail (es, fr, pt, pt-br), Gmail (es, fr, pt, pt-br), New Outlook 2019 (es, fr, pt, pt-br), Thunderbird (fr, pt, pt-br), HubSpot (es, fr, pt-br)
|
|
249
|
+
multiline `^(${HS}*Lähettäjä\s?:(.+))$`, // Apple Mail (fi), Gmail (fi), New Outlook 2019 (fi), Thunderbird (fi), HubSpot (fi)
|
|
250
|
+
multiline `^(${HS}*Šalje\s?:(.+))$`, // Apple Mail (hr), Gmail (hr), Thunderbird (hr)
|
|
251
|
+
multiline `^(${HS}*Feladó\s?:(.+))$`, // Apple Mail (hu), Gmail (hu), New Outlook 2019 (fr), Thunderbird (hu)
|
|
252
|
+
multiline `^(${HS}*Da\s?:(.+))$`, // Apple Mail (it), Gmail (it), New Outlook 2019 (it), HubSpot (it)
|
|
253
|
+
multiline `^(${HS}*Van\s?:(.+))$`, // Apple Mail (nl), Gmail (nl), New Outlook 2019 (nl), Thunderbird (nl), HubSpot (nl)
|
|
254
|
+
multiline `^(${HS}*Expeditorul\s?:(.+))$`, // Apple Mail (ro)
|
|
255
|
+
multiline `^(${HS}*Отправитель\s?:(.+))$`, // Apple Mail (ru)
|
|
256
|
+
multiline `^(${HS}*Från\s?:(.+))$`, // Apple Mail (sv), Gmail (sv), New Outlook 2019 (sv), Thunderbird (sv), HubSpot (sv)
|
|
257
|
+
multiline `^(${HS}*Kimden\s?:(.+))$`, // Apple Mail (tr), Thunderbird (tr)
|
|
258
|
+
multiline `^(${HS}*Від кого\s?:(.+))$`, // Apple Mail (uk)
|
|
259
|
+
multiline `^(${HS}*Saatja\s?:(.+))$`, // Gmail (et)
|
|
260
|
+
multiline `^(${HS}*De la\s?:(.+))$`, // Gmail (ro)
|
|
261
|
+
multiline `^(${HS}*Gönderen\s?:(.+))$`, // Gmail (tr)
|
|
262
|
+
multiline `^(${HS}*От\s?:(.+))$`, // Gmail (ru), New Outlook 2019 (ru), Thunderbird (ru)
|
|
263
|
+
multiline `^(${HS}*Від\s?:(.+))$`, // Gmail (uk), Thunderbird (uk)
|
|
264
|
+
multiline `^(${HS}*Mittente\s?:(.+))$`, // Thunderbird (it)
|
|
265
|
+
multiline `^(${HS}*Nadawca\s?:(.+))$`, // Thunderbird (pl)
|
|
266
|
+
multiline `^(${HS}*de la\s?:(.+))$`, // Thunderbird (ro)
|
|
267
|
+
multiline `^(${HS}*送信元:(.+))$` // HubSpot (ja)
|
|
216
268
|
],
|
|
217
269
|
original_from_lax: [
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
270
|
+
laxFromHeader("From"), // Yahoo Mail (en)
|
|
271
|
+
laxFromHeader("Od"), // Yahoo Mail (cs, pl, sk)
|
|
272
|
+
laxFromHeader("Fra"), // Yahoo Mail (da, no)
|
|
273
|
+
laxFromHeader("Von"), // Yahoo Mail (de)
|
|
274
|
+
laxFromHeader("De"), // Yahoo Mail (es, fr, pt, pt-br)
|
|
275
|
+
laxFromHeader("Lähettäjä"), // Yahoo Mail (fi)
|
|
276
|
+
laxFromHeader("Feladó"), // Yahoo Mail (hu)
|
|
277
|
+
laxFromHeader("Da"), // Yahoo Mail (it)
|
|
278
|
+
laxFromHeader("Van"), // Yahoo Mail (nl)
|
|
279
|
+
laxFromHeader("De la"), // Yahoo Mail (ro)
|
|
280
|
+
laxFromHeader("От"), // Yahoo Mail (ru)
|
|
281
|
+
laxFromHeader("Från"), // Yahoo Mail (sv)
|
|
282
|
+
laxFromHeader("Kimden"), // Yahoo Mail (tr)
|
|
283
|
+
laxFromHeader("Від") // Yahoo Mail (uk)
|
|
232
284
|
],
|
|
233
285
|
original_to: [
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
286
|
+
multiline `^\*?${HS}*To\s?:\*?(.+)$`, // Apple Mail (en), Gmail (all locales), Outlook Live / 365 (all locales), Thunderbird (da, en), Missive (en), HubSpot (en)
|
|
287
|
+
multiline `^${HS}*Komu\s?:(.+)$`, // Apple Mail (cs), New Outlook 2019 (cs, sk), Thunderbird (cs)
|
|
288
|
+
multiline `^${HS}*Til\s?:(.+)$`, // Apple Mail (da, no), New Outlook 2019 (da), Thunderbird (no)
|
|
289
|
+
multiline `^${HS}*An\s?:(.+)$`, // Apple Mail (de), New Outlook 2019 (de), Thunderbird (de), HubSpot (de)
|
|
290
|
+
multiline `^${HS}*Para\s?:(.+)$`, // Apple Mail (es, pt, pt-br), New Outlook 2019 (es, pt, pt-br), Thunderbird (es, pt, pt-br), HubSpot (pt-br)
|
|
291
|
+
multiline `^${HS}*Vastaanottaja\s?:(.+)$`, // Apple Mail (fi), New Outlook 2019 (fi), Thunderbird (fi), HubSpot (fi)
|
|
292
|
+
multiline `^${HS}*À\s?:(.+)$`, // Apple Mail (fr), New Outlook 2019 (fr), HubSpot (fr)
|
|
293
|
+
multiline `^${HS}*Prima\s?:(.+)$`, // Apple Mail (hr), Thunderbird (hr)
|
|
294
|
+
multiline `^${HS}*Címzett\s?:(.+)$`, // Apple Mail (hu), New Outlook 2019 (hu), Thunderbird (hu)
|
|
295
|
+
multiline `^${HS}*A\s?:(.+)$`, // Apple Mail (it), New Outlook 2019 (it), Thunderbird (it), HubSpot (es, it)
|
|
296
|
+
multiline `^${HS}*Aan\s?:(.+)$`, // Apple Mail (nl), New Outlook 2019 (nl), Thunderbird (nl), HubSpot (nl)
|
|
297
|
+
multiline `^${HS}*Do\s?:(.+)$`, // Apple Mail (pl), New Outlook 2019 (pl), HubSpot (pl)
|
|
298
|
+
multiline `^${HS}*Destinatarul\s?:(.+)$`, // Apple Mail (ro)
|
|
299
|
+
multiline `^${HS}*Кому\s?:(.+)$`, // Apple Mail (ru, uk), New Outlook 2019 (ru), Thunderbird (ru, uk)
|
|
300
|
+
multiline `^${HS}*Pre\s?:(.+)$`, // Apple Mail (sk), Thunderbird (sk)
|
|
301
|
+
multiline `^${HS}*Till\s?:(.+)$`, // Apple Mail (sv), New Outlook 2019 (sv), Thunderbird (sv)
|
|
302
|
+
multiline `^${HS}*Kime\s?:(.+)$`, // Apple Mail (tr), Thunderbird (tr)
|
|
303
|
+
multiline `^${HS}*Pour\s?:(.+)$`, // Thunderbird (fr)
|
|
304
|
+
multiline `^${HS}*Adresat\s?:(.+)$`, // Thunderbird (pl)
|
|
305
|
+
multiline `^${HS}*送信先:(.+)$` // HubSpot (ja)
|
|
254
306
|
],
|
|
255
307
|
original_to_lax: [
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
308
|
+
/(?<!\s)\s*To\s?:(.+)$/m, // Yahook Mail (en)
|
|
309
|
+
/(?<!\s)\s*Komu\s?:(.+)$/m, // Yahook Mail (cs, sk)
|
|
310
|
+
/(?<!\s)\s*Til\s?:(.+)$/m, // Yahook Mail (da, no, sv)
|
|
311
|
+
/(?<!\s)\s*An\s?:(.+)$/m, // Yahook Mail (de)
|
|
312
|
+
/(?<!\s)\s*Para\s?:(.+)$/m, // Yahook Mail (es, pt, pt-br)
|
|
313
|
+
/(?<!\s)\s*Vastaanottaja\s?:(.+)$/m, // Yahook Mail (fi)
|
|
314
|
+
/(?<!\s)\s*À\s?:(.+)$/m, // Yahook Mail (fr)
|
|
315
|
+
/(?<!\s)\s*Címzett\s?:(.+)$/m, // Yahook Mail (hu)
|
|
316
|
+
/(?<!\s)\s*A\s?:(.+)$/m, // Yahook Mail (it)
|
|
317
|
+
/(?<!\s)\s*Aan\s?:(.+)$/m, // Yahook Mail (nl)
|
|
318
|
+
/(?<!\s)\s*Do\s?:(.+)$/m, // Yahook Mail (pl)
|
|
319
|
+
/(?<!\s)\s*Către\s?:(.+)$/m, // Yahook Mail (ro), Thunderbird (ro)
|
|
320
|
+
/(?<!\s)\s*Кому\s?:(.+)$/m, // Yahook Mail (ru, uk)
|
|
321
|
+
/(?<!\s)\s*Till\s?:(.+)$/m, // Yahook Mail (sv)
|
|
322
|
+
/(?<!\s)\s*Kime\s?:(.+)$/m // Yahook Mail (tr)
|
|
271
323
|
],
|
|
272
324
|
original_reply_to: [
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
325
|
+
multiline `^${HS}*Reply-To\s?:(.+)$`, // Apple Mail (en)
|
|
326
|
+
multiline `^${HS}*Odgovori na\s?:(.+)$`, // Apple Mail (hr)
|
|
327
|
+
multiline `^${HS}*Odpověď na\s?:(.+)$`, // Apple Mail (cs)
|
|
328
|
+
multiline `^${HS}*Svar til\s?:(.+)$`, // Apple Mail (da)
|
|
329
|
+
multiline `^${HS}*Antwoord aan\s?:(.+)$`, // Apple Mail (nl)
|
|
330
|
+
multiline `^${HS}*Vastaus\s?:(.+)$`, // Apple Mail (fi)
|
|
331
|
+
multiline `^${HS}*Répondre à\s?:(.+)$`, // Apple Mail (fr)
|
|
332
|
+
multiline `^${HS}*Antwort an\s?:(.+)$`, // Apple Mail (de)
|
|
333
|
+
multiline `^${HS}*Válaszcím\s?:(.+)$`, // Apple Mail (hu)
|
|
334
|
+
multiline `^${HS}*Rispondi a\s?:(.+)$`, // Apple Mail (it)
|
|
335
|
+
multiline `^${HS}*Svar til\s?:(.+)$`, // Apple Mail (no)
|
|
336
|
+
multiline `^${HS}*Odpowiedź-do\s?:(.+)$`, // Apple Mail (pl)
|
|
337
|
+
multiline `^${HS}*Responder A\s?:(.+)$`, // Apple Mail (pt)
|
|
338
|
+
multiline `^${HS}*Responder a\s?:(.+)$`, // Apple Mail (pt-br, es)
|
|
339
|
+
multiline `^${HS}*Răspuns către\s?:(.+)$`, // Apple Mail (ro)
|
|
340
|
+
multiline `^${HS}*Ответ-Кому\s?:(.+)$`, // Apple Mail (ru)
|
|
341
|
+
multiline `^${HS}*Odpovedať-Pre\s?:(.+)$`, // Apple Mail (sk)
|
|
342
|
+
multiline `^${HS}*Svara till\s?:(.+)$`, // Apple Mail (sv)
|
|
343
|
+
multiline `^${HS}*Yanıt Adresi\s?:(.+)$`, // Apple Mail (tr)
|
|
344
|
+
multiline `^${HS}*Кому відповісти\s?:(.+)$` // Apple Mail (uk)
|
|
293
345
|
],
|
|
294
346
|
original_cc: [
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
347
|
+
multiline `^\*?${HS}*Cc\s?:\*?(.+)$`, // 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), HubSpot (de, en, es, it, nl, pt-br)
|
|
348
|
+
multiline `^${HS}*CC\s?:(.+)$`, // New Outlook 2019 (es, nl, pt), Thunderbird (da, en, es, fi, hr, hu, it, nl, no, pt, pt-br, ro, tr, uk)
|
|
349
|
+
multiline `^${HS}*Kopie\s?:(.+)$`, // Apple Mail (cs, de, nl), New Outlook 2019 (cs), Thunderbird (cs)
|
|
350
|
+
multiline `^${HS}*Kopio\s?:(.+)$`, // Apple Mail (fi), New Outlook 2019 (fi), HubSpot (fi)
|
|
351
|
+
multiline `^${HS}*Másolat\s?:(.+)$`, // Apple Mail (hu)
|
|
352
|
+
multiline `^${HS}*Kopi\s?:(.+)$`, // Apple Mail (no)
|
|
353
|
+
multiline `^${HS}*Dw\s?:(.+)$`, // Apple Mail (pl)
|
|
354
|
+
multiline `^${HS}*Копия\s?:(.+)$`, // Apple Mail (ru), New Outlook 2019 (ru), Thunderbird (ru)
|
|
355
|
+
multiline `^${HS}*Kopia\s?:(.+)$`, // Apple Mail (sv), New Outlook 2019 (sv), Thunderbird (pl, sv), HubSpot (sv)
|
|
356
|
+
multiline `^${HS}*Bilgi\s?:(.+)$`, // Apple Mail (tr)
|
|
357
|
+
multiline `^${HS}*Копія\s?:(.+)$`, // Apple Mail (uk),
|
|
358
|
+
multiline `^${HS}*Másolatot kap\s?:(.+)$`, // New Outlook 2019 (hu)
|
|
359
|
+
multiline `^${HS}*Kópia\s?:(.+)$`, // New Outlook 2019 (sk), Thunderbird (sk)
|
|
360
|
+
multiline `^${HS}*DW\s?:(.+)$`, // New Outlook 2019 (pl), HubSpot (pl)
|
|
361
|
+
multiline `^${HS}*Kopie \(CC\)\s?:(.+)$`, // Thunderbird (de)
|
|
362
|
+
multiline `^${HS}*Copie à\s?:(.+)$`, // Thunderbird (fr)
|
|
363
|
+
multiline `^${HS}*CC:(.+)$` // HubSpot (ja)
|
|
312
364
|
],
|
|
313
365
|
original_cc_lax: [
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
366
|
+
/(?<!\s)\s*Cc\s?:(.+)$/m, // Yahoo Mail (da, en, it, nl, pt, pt-br, ro, tr)
|
|
367
|
+
/(?<!\s)\s*CC\s?:(.+)$/m, // Yahoo Mail (de, es)
|
|
368
|
+
/(?<!\s)\s*Kopie\s?:(.+)$/m, // Yahoo Mail (cs)
|
|
369
|
+
/(?<!\s)\s*Kopio\s?:(.+)$/m, // Yahoo Mail (fi)
|
|
370
|
+
/(?<!\s)\s*Másolat\s?:(.+)$/m, // Yahoo Mail (hu)
|
|
371
|
+
/(?<!\s)\s*Kopi\s?:(.+)$/m, // Yahoo Mail (no)
|
|
372
|
+
/(?<!\s)\s*Dw\s?(.+)$/m, // Yahoo Mail (pl)
|
|
373
|
+
/(?<!\s)\s*Копия\s?:(.+)$/m, // Yahoo Mail (ru)
|
|
374
|
+
/(?<!\s)\s*Kópia\s?:(.+)$/m, // Yahoo Mail (sk)
|
|
375
|
+
/(?<!\s)\s*Kopia\s?:(.+)$/m, // Yahoo Mail (sv)
|
|
376
|
+
/(?<!\s)\s*Копія\s?:(.+)$/m // Yahoo Mail (uk)
|
|
325
377
|
],
|
|
326
378
|
original_date: [
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
379
|
+
multiline `^${HS}*Date\s?:(.+)$`, // Apple Mail (en, fr), Gmail (all locales), New Outlook 2019 (en, fr), Thunderbird (da, en, fr), Missive (en), HubSpot (en, fr)
|
|
380
|
+
multiline `^${HS}*Datum\s?:(.+)$`, // Apple Mail (cs, de, hr, nl, sv), New Outlook 2019 (cs, de, nl, sv), Thunderbird (cs, de, hr, nl, sv), HubSpot (de, nl, sv)
|
|
381
|
+
multiline `^${HS}*Dato\s?:(.+)$`, // Apple Mail (da, no), New Outlook 2019 (da), Thunderbird (no)
|
|
382
|
+
multiline `^${HS}*Envoyé\s?:(.+)$`, // New Outlook 2019 (fr)
|
|
383
|
+
multiline `^${HS}*Fecha\s?:(.+)$`, // Apple Mail (es), New Outlook 2019 (es), Thunderbird (es), HubSpot (es)
|
|
384
|
+
multiline `^${HS}*Päivämäärä\s?:(.+)$`, // Apple Mail (fi), New Outlook 2019 (fi), HubSpot (fi)
|
|
385
|
+
multiline `^${HS}*Dátum\s?:(.+)$`, // Apple Mail (hu, sk), New Outlook 2019 (sk), Thunderbird (hu, sk)
|
|
386
|
+
multiline `^${HS}*Data\s?:(.+)$`, // Apple Mail (it, pl, pt, pt-br), New Outlook 2019 (it, pl, pt, pt-br), Thunderbird (it, pl, pt, pt-br), HubSpot (it, pl, pt-br)
|
|
387
|
+
multiline `^${HS}*Dată\s?:(.+)$`, // Apple Mail (ro), Thunderbird (ro)
|
|
388
|
+
multiline `^${HS}*Дата\s?:(.+)$`, // Apple Mail (ru, uk), New Outlook 2019 (ru), Thunderbird (ru, uk)
|
|
389
|
+
multiline `^${HS}*Tarih\s?:(.+)$`, // Apple Mail (tr), Thunderbird (tr)
|
|
390
|
+
multiline `^\*?${HS}*Sent\s?:\*?(.+)$`, // Outlook Live / 365 (all locales)
|
|
391
|
+
multiline `^${HS}*Päiväys\s?:(.+)$`, // Thunderbird (fi)
|
|
392
|
+
multiline `^${HS}*日付:(.+)$` // HubSpot (ja)
|
|
341
393
|
],
|
|
342
394
|
original_date_lax: [
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
395
|
+
/(?<!\s)\s*Datum\s?:(.+)$/m, // Yahoo Mail (cs)
|
|
396
|
+
/(?<!\s)\s*Sendt\s?:(.+)$/m, // Yahoo Mail (da, no)
|
|
397
|
+
/(?<!\s)\s*Gesendet\s?:(.+)$/m, // Yahoo Mail (de)
|
|
398
|
+
/(?<!\s)\s*Sent\s?:(.+)$/m, // Yahoo Mail (en)
|
|
399
|
+
/(?<!\s)\s*Enviado\s?:(.+)$/m, // Yahoo Mail (es, pt, pt-br)
|
|
400
|
+
/(?<!\s)\s*Envoyé\s?:(.+)$/m, // Yahoo Mail (fr)
|
|
401
|
+
/(?<!\s)\s*Lähetetty\s?:(.+)$/m, // Yahoo Mail (fi)
|
|
402
|
+
/(?<!\s)\s*Elküldve\s?:(.+)$/m, // Yahoo Mail (hu)
|
|
403
|
+
/(?<!\s)\s*Inviato\s?:(.+)$/m, // Yahoo Mail (it)
|
|
404
|
+
/(?<!\s)\s*Verzonden\s?:(.+)$/m, // Yahoo Mail (it)
|
|
405
|
+
/(?<!\s)\s*Wysłano\s?:(.+)$/m, // Yahoo Mail (pl)
|
|
406
|
+
/(?<!\s)\s*Trimis\s?:(.+)$/m, // Yahoo Mail (ro)
|
|
407
|
+
/(?<!\s)\s*Отправлено\s?:(.+)$/m, // Yahoo Mail (ru)
|
|
408
|
+
/(?<!\s)\s*Odoslané\s?:(.+)$/m, // Yahoo Mail (sk)
|
|
409
|
+
/(?<!\s)\s*Skickat\s?:(.+)$/m, // Yahoo Mail (sv)
|
|
410
|
+
/(?<!\s)\s*Gönderilen\s?:(.+)$/m, // Yahoo Mail (tr)
|
|
411
|
+
/(?<!\s)\s*Відправлено\s?:(.+)$/m // Yahoo Mail (uk)
|
|
360
412
|
],
|
|
361
413
|
mailbox: [
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
414
|
+
regex() `^\s*<.${upTo("<mailto:")}<mailto:(.${upTo(">>")})>>`, // "<walter.sheltan@acme.com<mailto:walter.sheltan@acme.com>>"
|
|
415
|
+
regex() `^(.${lazyWords("[^\\s<]")})\s*<.${upTo("<mailto:")}<mailto:(.${upTo(">>")})>>`, // "Walter Sheltan <walter.sheltan@acme.com<mailto:walter.sheltan@acme.com>>"
|
|
416
|
+
regex() `^(.${lazyWords(`(?!${OPEN}mailto:)\\S`)})\s*${OPEN}mailto:(.${upTo(CLOSE)})${CLOSE}`, // "Walter Sheltan <mailto:walter.sheltan@acme.com>" or "Walter Sheltan [mailto:walter.sheltan@acme.com]" or "walter.sheltan@acme.com <mailto:walter.sheltan@acme.com>"
|
|
417
|
+
regex() `^'(${upTo(`'\\s*${OPEN}`, "+")})'\s*${OPEN}(.${upTo(CLOSE)})${CLOSE}`, // "'Walter Sheltan' <walter.sheltan@acme.com>" or "'Walter Sheltan' [walter.sheltan@acme.com]" or "'walter.sheltan@acme.com' <walter.sheltan@acme.com>"
|
|
418
|
+
regex() `^"'(${upTo(`'"\\s*${OPEN}`, "+")})'"\s*${OPEN}(.${upTo(CLOSE)})${CLOSE}`, // ""'Walter Sheltan'" <walter.sheltan@acme.com>" or ""'Walter Sheltan'" [walter.sheltan@acme.com]" or ""'walter.sheltan@acme.com'" <walter.sheltan@acme.com>"
|
|
419
|
+
regex() `^"(${upTo(`"\\s*${OPEN}`, "+")})"\s*${OPEN}(.${upTo(CLOSE)})${CLOSE}`, // ""Walter Sheltan" <walter.sheltan@acme.com>" or ""Walter Sheltan" [walter.sheltan@acme.com]" or ""walter.sheltan@acme.com" <walter.sheltan@acme.com>"
|
|
420
|
+
regex() `^([^,;]${lazyWords("[^,;\\s\\[|<]", "\\s")})\s*${OPEN}(.${upTo(CLOSE)})${CLOSE}`, // "Walter Sheltan <walter.sheltan@acme.com>" or "Walter Sheltan [walter.sheltan@acme.com]" or "walter.sheltan@acme.com <walter.sheltan@acme.com>"
|
|
369
421
|
/^(.?)\s?\n?\s*[\[|<](.+?)[\]|>]/, // "<walter.sheltan@acme.com>"
|
|
370
422
|
/^([^\s@]+@[^\s@]+\.[^\s@,]+)/, // "walter.sheltan@acme.com"
|
|
371
|
-
|
|
423
|
+
regex() `^([^;].${lazyWords("[^\\s\\[|<]")})\s*${OPEN}(.${upTo(CLOSE)})${CLOSE}` // "Walter, Sheltan <walter.sheltan@acme.com>" or "Walter, Sheltan [walter.sheltan@acme.com]"
|
|
372
424
|
],
|
|
373
425
|
mailbox_address: [
|
|
374
|
-
/^(([^\s@]+)@([^\s@]+)\.([^\s@]+))$/
|
|
426
|
+
/^(?=[^\s@]+@[^\s@]+$)(([^\s@]+)@([^\s@]+)\.([^\s@]+))$/
|
|
375
427
|
]
|
|
376
|
-
/* eslint-enable max-len */
|
|
377
428
|
};
|
|
378
429
|
/**************************************************************************
|
|
379
430
|
* PARSER
|
|
@@ -515,7 +566,7 @@ class Parser {
|
|
|
515
566
|
const regexLine = this.buildLineRegex(regex);
|
|
516
567
|
builtLine.push(regexLine);
|
|
517
568
|
}
|
|
518
|
-
built.push(
|
|
569
|
+
built.push(new RegExp(regex));
|
|
519
570
|
}
|
|
520
571
|
regexesMap[key] = built;
|
|
521
572
|
if (LINE_REGEXES.includes(key)) {
|
|
@@ -528,7 +579,7 @@ class Parser {
|
|
|
528
579
|
if (LINE_REGEXES.includes(key)) {
|
|
529
580
|
regexesMap[keyLine] = this.buildLineRegex(single);
|
|
530
581
|
}
|
|
531
|
-
regexesMap[key] =
|
|
582
|
+
regexesMap[key] = new RegExp(single);
|
|
532
583
|
}
|
|
533
584
|
}
|
|
534
585
|
}
|
|
@@ -538,13 +589,7 @@ class Parser {
|
|
|
538
589
|
buildLineRegex(regex) {
|
|
539
590
|
// A 'line' regex will capture not only inner groups, but also the line \
|
|
540
591
|
// itself
|
|
541
|
-
|
|
542
|
-
// instance. It seems that under some inexplicable circumstances, \
|
|
543
|
-
// the RE2 instance sometimes doesn't have its `source` and `flags` \
|
|
544
|
-
// properties correctly populated.
|
|
545
|
-
const source = `(${regex.source})`;
|
|
546
|
-
const flags = regex.flags;
|
|
547
|
-
return buildSafeRegExp(source, flags);
|
|
592
|
+
return new RegExp(`(${regex.source})`, regex.flags);
|
|
548
593
|
}
|
|
549
594
|
/**
|
|
550
595
|
* Parses the body part
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
export declare function buildSafeRegExp(source: string | RegExp, flags?: string): RegExp;
|
|
1
|
+
/**************************************************************************
|
|
2
|
+
* FUNCTIONS
|
|
3
|
+
***************************************************************************/
|
|
5
4
|
type LoopRegexesMode = "match" | "split" | "replace";
|
|
6
5
|
type LoopRegexesResult<Mode extends LoopRegexesMode> = (Mode extends "replace" ? string : RegExpMatchArray);
|
|
7
6
|
/**
|
package/dist/utils.js
CHANGED
|
@@ -4,51 +4,10 @@
|
|
|
4
4
|
* Copyright (c) 2026 Crisp IM SAS
|
|
5
5
|
* All rights belong to Crisp IM SAS
|
|
6
6
|
*/
|
|
7
|
-
/**************************************************************************
|
|
8
|
-
* IMPORTS
|
|
9
|
-
***************************************************************************/
|
|
10
|
-
// NPM
|
|
11
|
-
import { createRequire } from "module";
|
|
12
|
-
const require = createRequire(import.meta.url);
|
|
13
|
-
/**************************************************************************
|
|
14
|
-
* INSTANCES
|
|
15
|
-
***************************************************************************/
|
|
16
|
-
const RE2Engine = detectRE2();
|
|
17
|
-
/**************************************************************************
|
|
18
|
-
* FUNCTIONS
|
|
19
|
-
***************************************************************************/
|
|
20
|
-
/**
|
|
21
|
-
* Detects whether the RE2 engine is available
|
|
22
|
-
*/
|
|
23
|
-
function detectRE2() {
|
|
24
|
-
// Notice: RE2 can be explicitly disabled, to test the RegExp fallback
|
|
25
|
-
if (process.env.EMAIL_FORWARD_PARSER_DISABLE_RE2) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
return require("re2");
|
|
30
|
-
}
|
|
31
|
-
catch (_a) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Builds a safe regular expression (RE2 when available, RegExp otherwise)
|
|
37
|
-
*/
|
|
38
|
-
export function buildSafeRegExp(source, flags) {
|
|
39
|
-
// Important: never pass an undefined 'flags', as RE2 would drop the flags
|
|
40
|
-
if (RE2Engine !== null) {
|
|
41
|
-
return ((flags === undefined)
|
|
42
|
-
? new RE2Engine(source)
|
|
43
|
-
: new RE2Engine(source, flags));
|
|
44
|
-
}
|
|
45
|
-
return ((flags === undefined) ? new RegExp(source) : new RegExp(source, flags));
|
|
46
|
-
}
|
|
47
7
|
/**
|
|
48
8
|
* Executes a regular expression on a string, in the given mode
|
|
49
9
|
*/
|
|
50
10
|
function executeRegex(regex, str, mode) {
|
|
51
|
-
// Notice: call String methods, as they support both RE2 and RegExp
|
|
52
11
|
switch (mode) {
|
|
53
12
|
case "replace": {
|
|
54
13
|
return str.replace(regex, "");
|
|
@@ -72,7 +31,7 @@ export function loopRegexes(regexes, str, mode = "match", highestPosition = true
|
|
|
72
31
|
let regex = regexes[i];
|
|
73
32
|
if (typeof regex === "string") {
|
|
74
33
|
// Build the regex
|
|
75
|
-
regex =
|
|
34
|
+
regex = new RegExp(regex);
|
|
76
35
|
}
|
|
77
36
|
const currentMatch = executeRegex(regex, (str || ""), mode);
|
|
78
37
|
if (mode === "replace") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "email-forward-parser",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.4",
|
|
4
4
|
"description": "Parses forwarded emails and extract content",
|
|
5
5
|
"author": "Eliott Vincent <eliott@crisp.chat>",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,15 +23,14 @@
|
|
|
23
23
|
},
|
|
24
24
|
"engineStrict": true,
|
|
25
25
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
26
|
+
"node": ">= 22.0.0"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "npx tsc",
|
|
30
30
|
"lint": "eslint .",
|
|
31
31
|
"unit": "node ./node_modules/nodeunit-x/bin/nodeunit test/index.js",
|
|
32
|
-
"unit:regexp": "EMAIL_FORWARD_PARSER_DISABLE_RE2=1 npm run unit",
|
|
33
32
|
"pretest": "npm run build",
|
|
34
|
-
"test": "npm run unit && npm run
|
|
33
|
+
"test": "npm run unit && npm run lint"
|
|
35
34
|
},
|
|
36
35
|
"keywords": [
|
|
37
36
|
"parser",
|
|
@@ -47,15 +46,6 @@
|
|
|
47
46
|
"eslint-plugin-crisp": "1.4.12",
|
|
48
47
|
"eslint-plugin-jsdoc": "54.1.0",
|
|
49
48
|
"nodeunit-x": "0.15.0",
|
|
50
|
-
"re2": "1.26.0",
|
|
51
49
|
"typescript": "5.9.2"
|
|
52
|
-
},
|
|
53
|
-
"peerDependencies": {
|
|
54
|
-
"re2": "1.x"
|
|
55
|
-
},
|
|
56
|
-
"peerDependenciesMeta": {
|
|
57
|
-
"re2": {
|
|
58
|
-
"optional": true
|
|
59
|
-
}
|
|
60
50
|
}
|
|
61
51
|
}
|