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 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
- ## RE2 Support
30
+ ## ReDoS Protection
31
31
 
32
- This library uses the [RE2](https://github.com/uhop/node-re2) regex engine when available for better performance and [ReDoS](https://en.wikipedia.org/wiki/ReDoS) protection. It automatically falls back to native JavaScript `RegExp` if RE2 is unavailable or fails to load.
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 { buildSafeRegExp, loopRegexes, reconciliateSplitMatch, trimString } from "./utils.js";
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
- /^>?\s*Begin forwarded message\s?:/m, // Apple Mail (en)
57
- /^>?\s*Začátek přeposílané zprávy\s?:/m, // Apple Mail (cs)
58
- /^>?\s*Start på videresendt besked\s?:/m, // Apple Mail (da)
59
- /^>?\s*Anfang der weitergeleiteten Nachricht\s?:/m, // Apple Mail (de)
60
- /^>?\s*Inicio del mensaje reenviado\s?:/m, // Apple Mail (es)
61
- /^>?\s*Välitetty viesti alkaa\s?:/m, // Apple Mail (fi)
62
- /^>?\s*Début du message réexpédié\s?:/m, // Apple Mail (fr)
63
- /^>?\s*Début du message transféré\s?:/m, // Apple Mail iOS (fr)
64
- /^>?\s*Započni proslijeđenu poruku\s?:/m, // Apple Mail (hr)
65
- /^>?\s*Továbbított levél kezdete\s?:/m, // Apple Mail (hu)
66
- /^>?\s*Inizio messaggio inoltrato\s?:/m, // Apple Mail (it)
67
- /^>?\s*Begin doorgestuurd bericht\s?:/m, // Apple Mail (nl)
68
- /^>?\s*Videresendt melding\s?:/m, // Apple Mail (no)
69
- /^>?\s*Początek przekazywanej wiadomości\s?:/m, // Apple Mail (pl)
70
- /^>?\s*Início da mensagem reencaminhada\s?:/m, // Apple Mail (pt)
71
- /^>?\s*Início da mensagem encaminhada\s?:/m, // Apple Mail (pt-br)
72
- /^>?\s*Începe mesajul redirecționat\s?:/m, // Apple Mail (ro)
73
- /^>?\s*Начало переадресованного сообщения\s?:/m, // Apple Mail (ro)
74
- /^>?\s*Začiatok preposlanej správy\s?:/m, // Apple Mail (sk)
75
- /^>?\s*Vidarebefordrat mejl\s?:/m, // Apple Mail (sv)
76
- /^>?\s*İleti başlangıcı\s?:/m, // Apple Mail (tr)
77
- /^>?\s*Початок листа, що пересилається\s?:/m, // Apple Mail (uk)
78
- /^\s*-{8,10}\s*Forwarded message\s*-{8,10}\s*/m, // Gmail (all locales), Missive (en), HubSpot (en)
79
- /^\s*_{32}\s*$/m, // Outlook Live / 365 (all locales)
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
- /^\s?Dne\s?.+\,\s?.+\s*[\[|<].+[\]|>]\s?napsal\(a\)\s?:/m, // Outlook 2019 (cz)
82
- /^\s?D.\s?.+\s?skrev\s?\".+\"\s*[\[|<].+[\]|>]\s?:/m, // Outlook 2019 (da)
83
- /^\s?Am\s?.+\s?schrieb\s?\".+\"\s*[\[|<].+[\]|>]\s?:/m, // Outlook 2019 (de)
84
- /^\s?On\s?.+\,\s?\".+\"\s*[\[|<].+[\]|>]\s?wrote\s?:/m, // Outlook 2019 (en)
85
- /^\s?El\s?.+\,\s?\".+\"\s*[\[|<].+[\]|>]\s?escribió\s?:/m, // Outlook 2019 (es)
86
- /^\s?Le\s?.+\,\s?«.+»\s*[\[|<].+[\]|>]\s?a écrit\s?:/m, // Outlook 2019 (fr)
87
- /^\s?.+\s*[\[|<].+[\]|>]\s?kirjoitti\s?.+\s?:/m, // Outlook 2019 (fi)
88
- /^\s?.+\s?időpontban\s?.+\s*[\[|<|(].+[\]|>|)]\s?ezt írta\s?:/m, // Outlook 2019 (hu)
89
- /^\s?Il giorno\s?.+\s?\".+\"\s*[\[|<].+[\]|>]\s?ha scritto\s?:/m, // Outlook 2019 (it)
90
- /^\s?Op\s?.+\s?heeft\s?.+\s*[\[|<].+[\]|>]\s?geschreven\s?:/m, // Outlook 2019 (nl)
91
- /^\s?.+\s*[\[|<].+[\]|>]\s?skrev følgende den\s?.+\s?:/m, // Outlook 2019 (no)
92
- /^\s?Dnia\s?.+\s?„.+”\s*[\[|<].+[\]|>]\s?napisał\s?:/m, // Outlook 2019 (pl)
93
- /^\s?Em\s?.+\,\s?\".+\"\s*[\[|<].+[\]|>]\s?escreveu\s?:/m, // Outlook 2019 (pt)
94
- /^\s?.+\s?пользователь\s?\".+\"\s*[\[|<].+[\]|>]\s?написал\s?:/m, // Outlook 2019 (ru)
95
- /^\s?.+\s?používateľ\s?.+\s*\([\[|<].+[\]|>]\)\s?napísal\s?:/m, // Outlook 2019 (sk)
96
- /^\s?Den\s?.+\s?skrev\s?\".+\"\s*[\[|<].+[\]|>]\s?följande\s?:/m, // Outlook 2019 (sv)
97
- /^\s?\".+\"\s*[\[|<].+[\]|>]\,\s?.+\s?tarihinde şunu yazdı\s?:/m, // Outlook 2019 (tr)
98
- /^\s*-{5,8} Přeposlaná zpráva -{5,8}\s*/m, // Yahoo Mail (cs), Thunderbird (cs)
99
- /^\s*-{5,8} Videresendt meddelelse -{5,8}\s*/m, // Yahoo Mail (da), Thunderbird (da)
100
- /^\s*-{5,10} Weitergeleitete Nachricht -{5,10}\s*/m, // Yahoo Mail (de), Thunderbird (de), HubSpot (de)
101
- /^\s*-{5,8} Forwarded Message -{5,8}\s*/m, // Yahoo Mail (en), Thunderbird (en)
102
- /^\s*-{5,10} Mensaje reenviado -{5,10}\s*/m, // Yahoo Mail (es), Thunderbird (es), HubSpot (es)
103
- /^\s*-{5,10} Edelleenlähetetty viesti -{5,10}\s*/m, // Yahoo Mail (fi), HubSpot (fi)
104
- /^\s*-{5} Message transmis -{5}\s*/m, // Yahoo Mail (fr)
105
- /^\s*-{5,8} Továbbított üzenet -{5,8}\s*/m, // Yahoo Mail (hu), Thunderbird (hu)
106
- /^\s*-{5,10} Messaggio inoltrato -{5,10}\s*/m, // Yahoo Mail (it), HubSpot (it)
107
- /^\s*-{5,10} Doorgestuurd bericht -{5,10}\s*/m, // Yahoo Mail (nl), Thunderbird (nl), HubSpot (nl)
108
- /^\s*-{5,8} Videresendt melding -{5,8}\s*/m, // Yahoo Mail (no), Thunderbird (no)
109
- /^\s*-{5} Przekazana wiadomość -{5}\s*/m, // Yahoo Mail (pl)
110
- /^\s*-{5,8} Mensagem reencaminhada -{5,8}\s*/m, // Yahoo Mail (pt), Thunderbird (pt)
111
- /^\s*-{5,10} Mensagem encaminhada -{5,10}\s*/m, // Yahoo Mail (pt-br), Thunderbird (pt-br), HubSpot (pt-br)
112
- /^\s*-{5,8} Mesaj redirecționat -{5,8}\s*/m, // Yahoo Mail (ro)
113
- /^\s*-{5} Пересылаемое сообщение -{5}\s*/m, // Yahoo Mail (ru)
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
- /^(\*?\s*From\s?:\*?(.+))$/m, // Apple Mail (en), Outlook Live / 365 (all locales), New Outlook 2019 (en), Thunderbird (da, en), Missive (en), HubSpot (en)
193
- /^(\s*Od\s?:(.+))$/m, // Apple Mail (cs, pl, sk), Gmail (cs, pl, sk), New Outlook 2019 (cs, pl, sk), Thunderbird (cs, sk), HubSpot (pl)
194
- /^(\s*Fra\s?:(.+))$/m, // Apple Mail (da, no), Gmail (da, no), New Outlook 2019 (da), Thunderbird (no)
195
- /^(\s*Von\s?:(.+))$/m, // Apple Mail (de), Gmail (de), New Outlook 2019 (de), Thunderbird (de), HubSpot (de)
196
- /^(\s*De\s?:(.+))$/m, // 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)
197
- /^(\s*Lähettäjä\s?:(.+))$/m, // Apple Mail (fi), Gmail (fi), New Outlook 2019 (fi), Thunderbird (fi), HubSpot (fi)
198
- /^(\s*Šalje\s?:(.+))$/m, // Apple Mail (hr), Gmail (hr), Thunderbird (hr)
199
- /^(\s*Feladó\s?:(.+))$/m, // Apple Mail (hu), Gmail (hu), New Outlook 2019 (fr), Thunderbird (hu)
200
- /^(\s*Da\s?:(.+))$/m, // Apple Mail (it), Gmail (it), New Outlook 2019 (it), HubSpot (it)
201
- /^(\s*Van\s?:(.+))$/m, // Apple Mail (nl), Gmail (nl), New Outlook 2019 (nl), Thunderbird (nl), HubSpot (nl)
202
- /^(\s*Expeditorul\s?:(.+))$/m, // Apple Mail (ro)
203
- /^(\s*Отправитель\s?:(.+))$/m, // Apple Mail (ru)
204
- /^(\s*Från\s?:(.+))$/m, // Apple Mail (sv), Gmail (sv), New Outlook 2019 (sv), Thunderbird (sv), HubSpot (sv)
205
- /^(\s*Kimden\s?:(.+))$/m, // Apple Mail (tr), Thunderbird (tr)
206
- /^(\s*Від кого\s?:(.+))$/m, // Apple Mail (uk)
207
- /^(\s*Saatja\s?:(.+))$/m, // Gmail (et)
208
- /^(\s*De la\s?:(.+))$/m, // Gmail (ro)
209
- /^(\s*Gönderen\s?:(.+))$/m, // Gmail (tr)
210
- /^(\s*От\s?:(.+))$/m, // Gmail (ru), New Outlook 2019 (ru), Thunderbird (ru)
211
- /^(\s*Від\s?:(.+))$/m, // Gmail (uk), Thunderbird (uk)
212
- /^(\s*Mittente\s?:(.+))$/m, // Thunderbird (it)
213
- /^(\s*Nadawca\s?:(.+))$/m, // Thunderbird (pl)
214
- /^(\s*de la\s?:(.+))$/m, // Thunderbird (ro)
215
- /^(\s*送信元:(.+))$/m // HubSpot (ja)
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
- /(\s*From\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/, // Yahoo Mail (en)
219
- /(\s*Od\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/, // Yahoo Mail (cs, pl, sk)
220
- /(\s*Fra\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/, // Yahoo Mail (da, no)
221
- /(\s*Von\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/, // Yahoo Mail (de)
222
- /(\s*De\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/, // Yahoo Mail (es, fr, pt, pt-br)
223
- /(\s*Lähettäjä\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/, // Yahoo Mail (fi)
224
- /(\s*Feladó\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/, // Yahoo Mail (hu)
225
- /(\s*Da\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/, // Yahoo Mail (it)
226
- /(\s*Van\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/, // Yahoo Mail (nl)
227
- /(\s*De la\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/, // Yahoo Mail (ro)
228
- /(\s*От\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/, // Yahoo Mail (ru)
229
- /(\s*Från\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/, // Yahoo Mail (sv)
230
- /(\s*Kimden\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/, // Yahoo Mail (tr)
231
- /(\s*Від\s?:(.+?)\s?\n?\s*[\[|<](.+?)[\]|>])/ // Yahoo Mail (uk)
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
- /^\*?\s*To\s?:\*?(.+)$/m, // Apple Mail (en), Gmail (all locales), Outlook Live / 365 (all locales), Thunderbird (da, en), Missive (en), HubSpot (en)
235
- /^\s*Komu\s?:(.+)$/m, // Apple Mail (cs), New Outlook 2019 (cs, sk), Thunderbird (cs)
236
- /^\s*Til\s?:(.+)$/m, // Apple Mail (da, no), New Outlook 2019 (da), Thunderbird (no)
237
- /^\s*An\s?:(.+)$/m, // Apple Mail (de), New Outlook 2019 (de), Thunderbird (de), HubSpot (de)
238
- /^\s*Para\s?:(.+)$/m, // Apple Mail (es, pt, pt-br), New Outlook 2019 (es, pt, pt-br), Thunderbird (es, pt, pt-br), HubSpot (pt-br)
239
- /^\s*Vastaanottaja\s?:(.+)$/m, // Apple Mail (fi), New Outlook 2019 (fi), Thunderbird (fi), HubSpot (fi)
240
- /^\s*À\s?:(.+)$/m, // Apple Mail (fr), New Outlook 2019 (fr), HubSpot (fr)
241
- /^\s*Prima\s?:(.+)$/m, // Apple Mail (hr), Thunderbird (hr)
242
- /^\s*Címzett\s?:(.+)$/m, // Apple Mail (hu), New Outlook 2019 (hu), Thunderbird (hu)
243
- /^\s*A\s?:(.+)$/m, // Apple Mail (it), New Outlook 2019 (it), Thunderbird (it), HubSpot (es, it)
244
- /^\s*Aan\s?:(.+)$/m, // Apple Mail (nl), New Outlook 2019 (nl), Thunderbird (nl), HubSpot (nl)
245
- /^\s*Do\s?:(.+)$/m, // Apple Mail (pl), New Outlook 2019 (pl), HubSpot (pl)
246
- /^\s*Destinatarul\s?:(.+)$/m, // Apple Mail (ro)
247
- /^\s*Кому\s?:(.+)$/m, // Apple Mail (ru, uk), New Outlook 2019 (ru), Thunderbird (ru, uk)
248
- /^\s*Pre\s?:(.+)$/m, // Apple Mail (sk), Thunderbird (sk)
249
- /^\s*Till\s?:(.+)$/m, // Apple Mail (sv), New Outlook 2019 (sv), Thunderbird (sv)
250
- /^\s*Kime\s?:(.+)$/m, // Apple Mail (tr), Thunderbird (tr)
251
- /^\s*Pour\s?:(.+)$/m, // Thunderbird (fr)
252
- /^\s*Adresat\s?:(.+)$/m, // Thunderbird (pl)
253
- /^\s*送信先:(.+)$/m // HubSpot (ja)
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
- /\s*To\s?:(.+)$/m, // Yahook Mail (en)
257
- /\s*Komu\s?:(.+)$/m, // Yahook Mail (cs, sk)
258
- /\s*Til\s?:(.+)$/m, // Yahook Mail (da, no, sv)
259
- /\s*An\s?:(.+)$/m, // Yahook Mail (de)
260
- /\s*Para\s?:(.+)$/m, // Yahook Mail (es, pt, pt-br)
261
- /\s*Vastaanottaja\s?:(.+)$/m, // Yahook Mail (fi)
262
- /\s*À\s?:(.+)$/m, // Yahook Mail (fr)
263
- /\s*Címzett\s?:(.+)$/m, // Yahook Mail (hu)
264
- /\s*A\s?:(.+)$/m, // Yahook Mail (it)
265
- /\s*Aan\s?:(.+)$/m, // Yahook Mail (nl)
266
- /\s*Do\s?:(.+)$/m, // Yahook Mail (pl)
267
- /\s*Către\s?:(.+)$/m, // Yahook Mail (ro), Thunderbird (ro)
268
- /\s*Кому\s?:(.+)$/m, // Yahook Mail (ru, uk)
269
- /\s*Till\s?:(.+)$/m, // Yahook Mail (sv)
270
- /\s*Kime\s?:(.+)$/m // Yahook Mail (tr)
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
- /^\s*Reply-To\s?:(.+)$/m, // Apple Mail (en)
274
- /^\s*Odgovori na\s?:(.+)$/m, // Apple Mail (hr)
275
- /^\s*Odpověď na\s?:(.+)$/m, // Apple Mail (cs)
276
- /^\s*Svar til\s?:(.+)$/m, // Apple Mail (da)
277
- /^\s*Antwoord aan\s?:(.+)$/m, // Apple Mail (nl)
278
- /^\s*Vastaus\s?:(.+)$/m, // Apple Mail (fi)
279
- /^\s*Répondre à\s?:(.+)$/m, // Apple Mail (fr)
280
- /^\s*Antwort an\s?:(.+)$/m, // Apple Mail (de)
281
- /^\s*Válaszcím\s?:(.+)$/m, // Apple Mail (hu)
282
- /^\s*Rispondi a\s?:(.+)$/m, // Apple Mail (it)
283
- /^\s*Svar til\s?:(.+)$/m, // Apple Mail (no)
284
- /^\s*Odpowiedź-do\s?:(.+)$/m, // Apple Mail (pl)
285
- /^\s*Responder A\s?:(.+)$/m, // Apple Mail (pt)
286
- /^\s*Responder a\s?:(.+)$/m, // Apple Mail (pt-br, es)
287
- /^\s*Răspuns către\s?:(.+)$/m, // Apple Mail (ro)
288
- /^\s*Ответ-Кому\s?:(.+)$/m, // Apple Mail (ru)
289
- /^\s*Odpovedať-Pre\s?:(.+)$/m, // Apple Mail (sk)
290
- /^\s*Svara till\s?:(.+)$/m, // Apple Mail (sv)
291
- /^\s*Yanıt Adresi\s?:(.+)$/m, // Apple Mail (tr)
292
- /^\s*Кому відповісти\s?:(.+)$/m // Apple Mail (uk)
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
- /^\*?\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), HubSpot (de, en, es, it, nl, pt-br)
296
- /^\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)
297
- /^\s*Kopie\s?:(.+)$/m, // Apple Mail (cs, de, nl), New Outlook 2019 (cs), Thunderbird (cs)
298
- /^\s*Kopio\s?:(.+)$/m, // Apple Mail (fi), New Outlook 2019 (fi), HubSpot (fi)
299
- /^\s*Másolat\s?:(.+)$/m, // Apple Mail (hu)
300
- /^\s*Kopi\s?:(.+)$/m, // Apple Mail (no)
301
- /^\s*Dw\s?:(.+)$/m, // Apple Mail (pl)
302
- /^\s*Копия\s?:(.+)$/m, // Apple Mail (ru), New Outlook 2019 (ru), Thunderbird (ru)
303
- /^\s*Kopia\s?:(.+)$/m, // Apple Mail (sv), New Outlook 2019 (sv), Thunderbird (pl, sv), HubSpot (sv)
304
- /^\s*Bilgi\s?:(.+)$/m, // Apple Mail (tr)
305
- /^\s*Копія\s?:(.+)$/m, // Apple Mail (uk),
306
- /^\s*Másolatot kap\s?:(.+)$/m, // New Outlook 2019 (hu)
307
- /^\s*Kópia\s?:(.+)$/m, // New Outlook 2019 (sk), Thunderbird (sk)
308
- /^\s*DW\s?:(.+)$/m, // New Outlook 2019 (pl), HubSpot (pl)
309
- /^\s*Kopie \(CC\)\s?:(.+)$/m, // Thunderbird (de)
310
- /^\s*Copie à\s?:(.+)$/m, // Thunderbird (fr)
311
- /^\s*CC:(.+)$/m // HubSpot (ja)
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
- /\s*Cc\s?:(.+)$/m, // Yahoo Mail (da, en, it, nl, pt, pt-br, ro, tr)
315
- /\s*CC\s?:(.+)$/m, // Yahoo Mail (de, es)
316
- /\s*Kopie\s?:(.+)$/m, // Yahoo Mail (cs)
317
- /\s*Kopio\s?:(.+)$/m, // Yahoo Mail (fi)
318
- /\s*Másolat\s?:(.+)$/m, // Yahoo Mail (hu)
319
- /\s*Kopi\s?:(.+)$/m, // Yahoo Mail (no)
320
- /\s*Dw\s?(.+)$/m, // Yahoo Mail (pl)
321
- /\s*Копия\s?:(.+)$/m, // Yahoo Mail (ru)
322
- /\s*Kópia\s?:(.+)$/m, // Yahoo Mail (sk)
323
- /\s*Kopia\s?:(.+)$/m, // Yahoo Mail (sv)
324
- /\s*Копія\s?:(.+)$/m // Yahoo Mail (uk)
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
- /^\s*Date\s?:(.+)$/m, // Apple Mail (en, fr), Gmail (all locales), New Outlook 2019 (en, fr), Thunderbird (da, en, fr), Missive (en), HubSpot (en, fr)
328
- /^\s*Datum\s?:(.+)$/m, // Apple Mail (cs, de, hr, nl, sv), New Outlook 2019 (cs, de, nl, sv), Thunderbird (cs, de, hr, nl, sv), HubSpot (de, nl, sv)
329
- /^\s*Dato\s?:(.+)$/m, // Apple Mail (da, no), New Outlook 2019 (da), Thunderbird (no)
330
- /^\s*Envoyé\s?:(.+)$/m, // New Outlook 2019 (fr)
331
- /^\s*Fecha\s?:(.+)$/m, // Apple Mail (es), New Outlook 2019 (es), Thunderbird (es), HubSpot (es)
332
- /^\s*Päivämäärä\s?:(.+)$/m, // Apple Mail (fi), New Outlook 2019 (fi), HubSpot (fi)
333
- /^\s*Dátum\s?:(.+)$/m, // Apple Mail (hu, sk), New Outlook 2019 (sk), Thunderbird (hu, sk)
334
- /^\s*Data\s?:(.+)$/m, // 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)
335
- /^\s*Dată\s?:(.+)$/m, // Apple Mail (ro), Thunderbird (ro)
336
- /^\s*Дата\s?:(.+)$/m, // Apple Mail (ru, uk), New Outlook 2019 (ru), Thunderbird (ru, uk)
337
- /^\s*Tarih\s?:(.+)$/m, // Apple Mail (tr), Thunderbird (tr)
338
- /^\*?\s*Sent\s?:\*?(.+)$/m, // Outlook Live / 365 (all locales)
339
- /^\s*Päiväys\s?:(.+)$/m, // Thunderbird (fi)
340
- /^\s*日付:(.+)$/m // HubSpot (ja)
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
- /\s*Datum\s?:(.+)$/m, // Yahoo Mail (cs)
344
- /\s*Sendt\s?:(.+)$/m, // Yahoo Mail (da, no)
345
- /\s*Gesendet\s?:(.+)$/m, // Yahoo Mail (de)
346
- /\s*Sent\s?:(.+)$/m, // Yahoo Mail (en)
347
- /\s*Enviado\s?:(.+)$/m, // Yahoo Mail (es, pt, pt-br)
348
- /\s*Envoyé\s?:(.+)$/m, // Yahoo Mail (fr)
349
- /\s*Lähetetty\s?:(.+)$/m, // Yahoo Mail (fi)
350
- /\s*Elküldve\s?:(.+)$/m, // Yahoo Mail (hu)
351
- /\s*Inviato\s?:(.+)$/m, // Yahoo Mail (it)
352
- /\s*Verzonden\s?:(.+)$/m, // Yahoo Mail (it)
353
- /\s*Wysłano\s?:(.+)$/m, // Yahoo Mail (pl)
354
- /\s*Trimis\s?:(.+)$/m, // Yahoo Mail (ro)
355
- /\s*Отправлено\s?:(.+)$/m, // Yahoo Mail (ru)
356
- /\s*Odoslané\s?:(.+)$/m, // Yahoo Mail (sk)
357
- /\s*Skickat\s?:(.+)$/m, // Yahoo Mail (sv)
358
- /\s*Gönderilen\s?:(.+)$/m, // Yahoo Mail (tr)
359
- /\s*Відправлено\s?:(.+)$/m // Yahoo Mail (uk)
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
- /^\s?\n?\s*<.+?<mailto\:(.+?)>>/, // "<walter.sheltan@acme.com<mailto:walter.sheltan@acme.com>>"
363
- /^(.+?)\s?\n?\s*<.+?<mailto\:(.+?)>>/, // "Walter Sheltan <walter.sheltan@acme.com<mailto:walter.sheltan@acme.com>>"
364
- /^(.+?)\s?\n?\s*[\[|<]mailto\:(.+?)[\]|>]/, // "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>"
365
- /^\'(.+?)\'\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>"
366
- /^\"\'(.+?)\'\"\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>"
367
- /^\"(.+?)\"\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>"
368
- /^([^,;]+?)\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>"
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
- /^([^;].+?)\s?\n?\s*[\[|<](.+?)[\]|>]/ // "Walter, Sheltan <walter.sheltan@acme.com>" or "Walter, Sheltan [walter.sheltan@acme.com]"
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(buildSafeRegExp(regex));
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] = buildSafeRegExp(single);
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
- // Important: `regex` must be a raw regular expression literal, not an RE2 \
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
- * Builds a safe regular expression (RE2 when available, RegExp otherwise)
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 = buildSafeRegExp(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",
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": ">= 20.0.0"
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 unit:regexp && npm run lint"
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
  }