email-forward-parser 1.0.23 → 1.2.0
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 -1
- package/lib/parser.js +63 -52
- package/lib/utils.js +41 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ _👋 You use this library and you want to be listed there? [Contact us](https:/
|
|
|
24
24
|
## Features
|
|
25
25
|
|
|
26
26
|
This library is used at [Crisp](https://crisp.chat/) everyday with around 1 million inbound emails.
|
|
27
|
-
* Supported clients: Apple Mail, Gmail, Outlook Live / 365, Outlook 2013, Outlook 2019, New Outlook 2019, Yahoo Mail, Thunderbird, Missive
|
|
27
|
+
* Supported clients: Apple Mail, Gmail, Outlook Live / 365, Outlook 2013, Outlook 2019, New Outlook 2019, Yahoo Mail, Thunderbird, Missive, HubSpot
|
|
28
28
|
* Supported locales: Croatian, Czech, Danish, Dutch, English, French, Finnish, German, Hungarian, Italian, Norwegian, Polish, Portuguese (Brazil), Portuguese (Portugal), Romanian, Russian, Slovak, Spanish, Swedish, Turkish, Ukrainian
|
|
29
29
|
|
|
30
30
|
## Usage
|
|
@@ -96,6 +96,7 @@ New Outlook 2019 | Yes | No | Yes | -- | Yes | Yes | --
|
|
|
96
96
|
Yahoo Mail | Yes | Yes | No | Yes | Yes | Yes | The original information are all stuck to each other, without line breaks
|
|
97
97
|
Thunderbird | Yes | Yes | No | Yes | Yes | Yes | --
|
|
98
98
|
Missive | Yes | Yes | No | No | Yes | No | --
|
|
99
|
+
HubSpot | Yes | Yes | Yes | Yes | Yes | Yes | --
|
|
99
100
|
|
|
100
101
|
## Contributing
|
|
101
102
|
|
package/lib/parser.js
CHANGED
|
@@ -16,6 +16,7 @@ var REGEXES = {
|
|
|
16
16
|
four_spaces : /^(\ {4})\s?/gm, // Outlook 2019
|
|
17
17
|
carriage_return : /\r\n/gm, // Outlook 2019
|
|
18
18
|
byte_order_mark : /[\uFEFF]/gm, // Outlook 2019
|
|
19
|
+
non_breaking_space : /[\u00A0]/gm, // HubSpot
|
|
19
20
|
|
|
20
21
|
subject : [
|
|
21
22
|
/^Fw:(.*)/m, // Outlook Live / 365 (cs, en, hr, hu, sk), Yahoo Mail (all locales)
|
|
@@ -59,7 +60,7 @@ var REGEXES = {
|
|
|
59
60
|
/^>?\s*Vidarebefordrat mejl\s?:/m, // Apple Mail (sv)
|
|
60
61
|
/^>?\s*İleti başlangıcı\s?:/m, // Apple Mail (tr)
|
|
61
62
|
/^>?\s*Початок листа, що пересилається\s?:/m, // Apple Mail (uk)
|
|
62
|
-
/^\s*-{8,10}\s*Forwarded message\s*-{8,10}\s*/m, // Gmail (all locales), Missive (en)
|
|
63
|
+
/^\s*-{8,10}\s*Forwarded message\s*-{8,10}\s*/m, // Gmail (all locales), Missive (en), HubSpot (en)
|
|
63
64
|
/^\s*_{32}\s*$/m, // Outlook Live / 365 (all locales)
|
|
64
65
|
/^\s?Dne\s?.+\,\s?.+\s*[\[|<].+[\]|>]\s?napsal\(a\)\s?:/m, // Outlook 2019 (cz)
|
|
65
66
|
/^\s?D.\s?.+\s?skrev\s?\".+\"\s*[\[|<].+[\]|>]\s?:/m, // Outlook 2019 (da)
|
|
@@ -80,33 +81,35 @@ var REGEXES = {
|
|
|
80
81
|
/^\s?\".+\"\s*[\[|<].+[\]|>]\,\s?.+\s?tarihinde şunu yazdı\s?:/m, // Outlook 2019 (tr)
|
|
81
82
|
/\s*-{5,8} Přeposlaná zpráva -{5,8}\s*/m, // Yahoo Mail (cs), Thunderbird (cs)
|
|
82
83
|
/\s*-{5,8} Videresendt meddelelse -{5,8}\s*/m, // Yahoo Mail (da), Thunderbird (da)
|
|
83
|
-
/\s*-{5,
|
|
84
|
+
/\s*-{5,10} Weitergeleitete Nachricht -{5,10}\s*/m, // Yahoo Mail (de), Thunderbird (de), HubSpot (de)
|
|
84
85
|
/\s*-{5,8} Forwarded Message -{5,8}\s*/m, // Yahoo Mail (en), Thunderbird (en)
|
|
85
|
-
/\s*-{5,
|
|
86
|
-
/\s*-{5} Edelleenlähetetty viesti -{5}\s*/m, // Yahoo Mail (fi)
|
|
86
|
+
/\s*-{5,10} Mensaje reenviado -{5,10}\s*/m, // Yahoo Mail (es), Thunderbird (es), HubSpot (es)
|
|
87
|
+
/\s*-{5,10} Edelleenlähetetty viesti -{5,10}\s*/m, // Yahoo Mail (fi), HubSpot (fi)
|
|
87
88
|
/\s*-{5} Message transmis -{5}\s*/m, // Yahoo Mail (fr)
|
|
88
89
|
/\s*-{5,8} Továbbított üzenet -{5,8}\s*/m, // Yahoo Mail (hu), Thunderbird (hu)
|
|
89
|
-
/\s*-{5} Messaggio inoltrato -{5}\s*/m, // Yahoo Mail (it)
|
|
90
|
-
/\s*-{5,
|
|
90
|
+
/\s*-{5,10} Messaggio inoltrato -{5,10}\s*/m, // Yahoo Mail (it), HubSpot (it)
|
|
91
|
+
/\s*-{5,10} Doorgestuurd bericht -{5,10}\s*/m, // Yahoo Mail (nl), Thunderbird (nl), HubSpot (nl)
|
|
91
92
|
/\s*-{5,8} Videresendt melding -{5,8}\s*/m, // Yahoo Mail (no), Thunderbird (no)
|
|
92
93
|
/\s*-{5} Przekazana wiadomość -{5}\s*/m, // Yahoo Mail (pl)
|
|
93
94
|
/\s*-{5,8} Mensagem reencaminhada -{5,8}\s*/m, // Yahoo Mail (pt), Thunderbird (pt)
|
|
94
|
-
/\s*-{5,
|
|
95
|
+
/\s*-{5,10} Mensagem encaminhada -{5,10}\s*/m, // Yahoo Mail (pt-br), Thunderbird (pt-br), HubSpot (pt-br)
|
|
95
96
|
/\s*-{5,8} Mesaj redirecționat -{5,8}\s*/m, // Yahoo Mail (ro)
|
|
96
97
|
/\s*-{5} Пересылаемое сообщение -{5}\s*/m, // Yahoo Mail (ru)
|
|
97
98
|
/\s*-{5} Preposlaná správa -{5}\s*/m, // Yahoo Mail (sk)
|
|
98
|
-
/\s*-{5,
|
|
99
|
+
/\s*-{5,10} Vidarebefordrat meddelande -{5,10}\s*/m, // Yahoo Mail (sv), Thunderbird (sv), HubSpot (sv)
|
|
99
100
|
/\s*-{5} İletilmiş Mesaj -{5}\s*/m, // Yahoo Mail (tr)
|
|
100
101
|
/\s*-{5} Перенаправлене повідомлення -{5}\s*/m, // Yahoo Mail (uk)
|
|
101
102
|
/\s*-{8} Välitetty viesti \/ Fwd.Msg -{8}\s*/m, // Thunderbird (fi)
|
|
102
|
-
/\s*-{8} Message transféré -{8}\s*/m, // Thunderbird (fr)
|
|
103
|
+
/\s*-{8,10} Message transféré -{8,10}\s*/m, // Thunderbird (fr), HubSpot (fr)
|
|
103
104
|
/\s*-{8} Proslijeđena poruka -{8}\s*/m, // Thunderbird (hr)
|
|
104
105
|
/\s*-{8} Messaggio Inoltrato -{8}\s*/m, // Thunderbird (it)
|
|
105
106
|
/\s*-{3} Treść przekazanej wiadomości -{3}\s*/m, // Thunderbird (pl)
|
|
106
107
|
/\s*-{8} Перенаправленное сообщение -{8}\s*/m, // Thunderbird (ru)
|
|
107
108
|
/\s*-{8} Preposlaná správa --- Forwarded Message -{8}\s*/m, // Thunderbird (sk)
|
|
108
109
|
/\s*-{8} İletilen İleti -{8}\s*/m, // Thunderbird (tr)
|
|
109
|
-
/\s*-{8} Переслане повідомлення -{8}\s*/m // Thunderbird (uk)
|
|
110
|
+
/\s*-{8} Переслане повідомлення -{8}\s*/m, // Thunderbird (uk)
|
|
111
|
+
/\s*-{9,10} メッセージを転送 -{9,10}\s*/m, // HubSpot (ja)
|
|
112
|
+
/\s*-{9,10} Wiadomość przesłana dalej -{9,10}\s*/m // HubSpot (pl)
|
|
110
113
|
],
|
|
111
114
|
|
|
112
115
|
separator_with_information : [
|
|
@@ -130,25 +133,26 @@ var REGEXES = {
|
|
|
130
133
|
],
|
|
131
134
|
|
|
132
135
|
original_subject : [
|
|
133
|
-
/^\*?Subject\s?:\*?(.+)/im, // Apple Mail (en), Gmail (all locales), Outlook Live / 365 (all locales), New Outlook 2019 (en), Thunderbird (da, en), Missive (en)
|
|
136
|
+
/^\*?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)
|
|
134
137
|
/^Předmět\s?:(.+)/im, // Apple Mail (cs), New Outlook 2019 (cs), Thunderbird (cs)
|
|
135
138
|
/^Emne\s?:(.+)/im, // Apple Mail (da, no), New Outlook 2019 (da), Thunderbird (no)
|
|
136
|
-
/^Betreff\s?:(.+)/im, // Apple Mail (de), New Outlook 2019 (de), Thunderbird (de)
|
|
137
|
-
/^Asunto\s?:(.+)/im, // Apple Mail (es), New Outlook 2019 (es), Thunderbird (es)
|
|
138
|
-
/^Aihe\s?:(.+)/im, // Apple Mail (fi), New Outlook 2019 (fi), Thunderbird (fi)
|
|
139
|
-
/^Objet\s?:(.+)/im, // Apple Mail (fr), New Outlook 2019 (fr)
|
|
139
|
+
/^Betreff\s?:(.+)/im, // Apple Mail (de), New Outlook 2019 (de), Thunderbird (de), HubSpot (de)
|
|
140
|
+
/^Asunto\s?:(.+)/im, // Apple Mail (es), New Outlook 2019 (es), Thunderbird (es), HubSpot (es)
|
|
141
|
+
/^Aihe\s?:(.+)/im, // Apple Mail (fi), New Outlook 2019 (fi), Thunderbird (fi), HubSpot (fi)
|
|
142
|
+
/^Objet\s?:(.+)/im, // Apple Mail (fr), New Outlook 2019 (fr), HubSpot (fr)
|
|
140
143
|
/^Predmet\s?:(.+)/im, // Apple Mail (hr, sk), New Outlook 2019 (sk), Thunderbird (sk)
|
|
141
144
|
/^Tárgy\s?:(.+)/im, // Apple Mail (hu), New Outlook 2019 (hu), Thunderbird (hu)
|
|
142
|
-
/^Oggetto\s?:(.+)/im, // Apple Mail (it), New Outlook 2019 (it), Thunderbird (it)
|
|
143
|
-
/^Onderwerp\s?:(.+)/im, // Apple Mail (nl), New Outlook 2019 (nl), Thunderbird (nl)
|
|
144
|
-
/^Temat\s?:(.+)/im, // Apple Mail (pl), New Outlook 2019 (pl), Thunderbird (pl)
|
|
145
|
-
/^Assunto\s?:(.+)/im, // Apple Mail (pt, pt-br), New Outlook 2019 (pt, pt-br), Thunderbird (pt, pt-br)
|
|
145
|
+
/^Oggetto\s?:(.+)/im, // Apple Mail (it), New Outlook 2019 (it), Thunderbird (it), HubSpot (it)
|
|
146
|
+
/^Onderwerp\s?:(.+)/im, // Apple Mail (nl), New Outlook 2019 (nl), Thunderbird (nl), HubSpot (nl)
|
|
147
|
+
/^Temat\s?:(.+)/im, // Apple Mail (pl), New Outlook 2019 (pl), Thunderbird (pl), HubSpot (pl)
|
|
148
|
+
/^Assunto\s?:(.+)/im, // Apple Mail (pt, pt-br), New Outlook 2019 (pt, pt-br), Thunderbird (pt, pt-br), HubSpot (pt-br)
|
|
146
149
|
/^Subiectul\s?:(.+)/im, // Apple Mail (ro), Thunderbird (ro)
|
|
147
150
|
/^Тема\s?:(.+)/im, // Apple Mail (ru, uk), New Outlook 2019 (ru), Thunderbird (ru, uk)
|
|
148
|
-
/^Ämne\s?:(.+)/im, // Apple Mail (sv), New Outlook 2019 (sv), Thunderbird (sv)
|
|
151
|
+
/^Ämne\s?:(.+)/im, // Apple Mail (sv), New Outlook 2019 (sv), Thunderbird (sv), HubSpot (sv)
|
|
149
152
|
/^Konu\s?:(.+)/im, // Apple Mail (tr), Thunderbird (tr)
|
|
150
153
|
/^Sujet\s?:(.+)/im, // Thunderbird (fr)
|
|
151
|
-
/^Naslov\s?:(.+)/im // Thunderbird (hr)
|
|
154
|
+
/^Naslov\s?:(.+)/im, // Thunderbird (hr)
|
|
155
|
+
/^件名:(.+)/im // HubSpot (ja)
|
|
152
156
|
],
|
|
153
157
|
|
|
154
158
|
original_subject_lax : [
|
|
@@ -172,19 +176,19 @@ var REGEXES = {
|
|
|
172
176
|
],
|
|
173
177
|
|
|
174
178
|
original_from : [
|
|
175
|
-
/^(\*?\s*From\s?:\*?(.+))$/m, // Apple Mail (en), Outlook Live / 365 (all locales), New Outlook 2019 (en), Thunderbird (da, en), Missive (en)
|
|
176
|
-
/^(\s*Od\s?:(.+))$/m, // Apple Mail (cs, pl, sk), Gmail (cs, pl, sk), New Outlook 2019 (cs, pl, sk), Thunderbird (cs, sk)
|
|
179
|
+
/^(\*?\s*From\s?:\*?(.+))$/m, // Apple Mail (en), Outlook Live / 365 (all locales), New Outlook 2019 (en), Thunderbird (da, en), Missive (en), HubSpot (en)
|
|
180
|
+
/^(\s*Od\s?:(.+))$/m, // Apple Mail (cs, pl, sk), Gmail (cs, pl, sk), New Outlook 2019 (cs, pl, sk), Thunderbird (cs, sk), HubSpot (pl)
|
|
177
181
|
/^(\s*Fra\s?:(.+))$/m, // Apple Mail (da, no), Gmail (da, no), New Outlook 2019 (da), Thunderbird (no)
|
|
178
|
-
/^(\s*Von\s?:(.+))$/m, // Apple Mail (de), Gmail (de), New Outlook 2019 (de), Thunderbird (de)
|
|
179
|
-
/^(\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)
|
|
180
|
-
/^(\s*Lähettäjä\s?:(.+))$/m, // Apple Mail (fi), Gmail (fi), New Outlook 2019 (fi), Thunderbird (fi)
|
|
182
|
+
/^(\s*Von\s?:(.+))$/m, // Apple Mail (de), Gmail (de), New Outlook 2019 (de), Thunderbird (de), HubSpot (de)
|
|
183
|
+
/^(\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)
|
|
184
|
+
/^(\s*Lähettäjä\s?:(.+))$/m, // Apple Mail (fi), Gmail (fi), New Outlook 2019 (fi), Thunderbird (fi), HubSpot (fi)
|
|
181
185
|
/^(\s*Šalje\s?:(.+))$/m, // Apple Mail (hr), Gmail (hr), Thunderbird (hr)
|
|
182
186
|
/^(\s*Feladó\s?:(.+))$/m, // Apple Mail (hu), Gmail (hu), New Outlook 2019 (fr), Thunderbird (hu)
|
|
183
|
-
/^(\s*Da\s?:(.+))$/m, // Apple Mail (it), Gmail (it), New Outlook 2019 (it)
|
|
184
|
-
/^(\s*Van\s?:(.+))$/m, // Apple Mail (nl), Gmail (nl), New Outlook 2019 (nl), Thunderbird (nl)
|
|
187
|
+
/^(\s*Da\s?:(.+))$/m, // Apple Mail (it), Gmail (it), New Outlook 2019 (it), HubSpot (it)
|
|
188
|
+
/^(\s*Van\s?:(.+))$/m, // Apple Mail (nl), Gmail (nl), New Outlook 2019 (nl), Thunderbird (nl), HubSpot (nl)
|
|
185
189
|
/^(\s*Expeditorul\s?:(.+))$/m, // Apple Mail (ro)
|
|
186
190
|
/^(\s*Отправитель\s?:(.+))$/m, // Apple Mail (ru)
|
|
187
|
-
/^(\s*Från\s?:(.+))$/m, // Apple Mail (sv), Gmail (sv), New Outlook 2019 (sv), Thunderbird (sv)
|
|
191
|
+
/^(\s*Från\s?:(.+))$/m, // Apple Mail (sv), Gmail (sv), New Outlook 2019 (sv), Thunderbird (sv), HubSpot (sv)
|
|
188
192
|
/^(\s*Kimden\s?:(.+))$/m, // Apple Mail (tr), Thunderbird (tr)
|
|
189
193
|
/^(\s*Від кого\s?:(.+))$/m, // Apple Mail (uk)
|
|
190
194
|
/^(\s*Saatja\s?:(.+))$/m, // Gmail (et)
|
|
@@ -194,7 +198,8 @@ var REGEXES = {
|
|
|
194
198
|
/^(\s*Від\s?:(.+))$/m, // Gmail (uk), Thunderbird (uk)
|
|
195
199
|
/^(\s*Mittente\s?:(.+))$/m, // Thunderbird (it)
|
|
196
200
|
/^(\s*Nadawca\s?:(.+))$/m, // Thunderbird (pl)
|
|
197
|
-
/^(\s*de la\s?:(.+))$/m // Thunderbird (ro)
|
|
201
|
+
/^(\s*de la\s?:(.+))$/m, // Thunderbird (ro)
|
|
202
|
+
/^(\s*送信元:(.+))$/m // HubSpot (ja)
|
|
198
203
|
],
|
|
199
204
|
|
|
200
205
|
original_from_lax : [
|
|
@@ -215,25 +220,26 @@ var REGEXES = {
|
|
|
215
220
|
],
|
|
216
221
|
|
|
217
222
|
original_to : [
|
|
218
|
-
/^\*?\s*To\s?:\*?(.+)$/m, // Apple Mail (en), Gmail (all locales), Outlook Live / 365 (all locales), Thunderbird (da, en), Missive (en)
|
|
223
|
+
/^\*?\s*To\s?:\*?(.+)$/m, // Apple Mail (en), Gmail (all locales), Outlook Live / 365 (all locales), Thunderbird (da, en), Missive (en), HubSpot (en)
|
|
219
224
|
/^\s*Komu\s?:(.+)$/m, // Apple Mail (cs), New Outlook 2019 (cs, sk), Thunderbird (cs)
|
|
220
225
|
/^\s*Til\s?:(.+)$/m, // Apple Mail (da, no), New Outlook 2019 (da), Thunderbird (no)
|
|
221
|
-
/^\s*An\s?:(.+)$/m, // Apple Mail (de), New Outlook 2019 (de), Thunderbird (de)
|
|
222
|
-
/^\s*Para\s?:(.+)$/m, // Apple Mail (es, pt, pt-br), New Outlook 2019 (es, pt, pt-br), Thunderbird (es, pt, pt-br)
|
|
223
|
-
/^\s*Vastaanottaja\s?:(.+)$/m, // Apple Mail (fi), New Outlook 2019 (fi), Thunderbird (fi)
|
|
224
|
-
/^\s*À\s?:(.+)$/m, // Apple Mail (fr), New Outlook 2019 (fr)
|
|
226
|
+
/^\s*An\s?:(.+)$/m, // Apple Mail (de), New Outlook 2019 (de), Thunderbird (de), HubSpot (de)
|
|
227
|
+
/^\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)
|
|
228
|
+
/^\s*Vastaanottaja\s?:(.+)$/m, // Apple Mail (fi), New Outlook 2019 (fi), Thunderbird (fi), HubSpot (fi)
|
|
229
|
+
/^\s*À\s?:(.+)$/m, // Apple Mail (fr), New Outlook 2019 (fr), HubSpot (fr)
|
|
225
230
|
/^\s*Prima\s?:(.+)$/m, // Apple Mail (hr), Thunderbird (hr)
|
|
226
231
|
/^\s*Címzett\s?:(.+)$/m, // Apple Mail (hu), New Outlook 2019 (hu), Thunderbird (hu)
|
|
227
|
-
/^\s*A\s?:(.+)$/m, // Apple Mail (it), New Outlook 2019 (it), Thunderbird (it)
|
|
228
|
-
/^\s*Aan\s?:(.+)$/m, // Apple Mail (nl), New Outlook 2019 (nl), Thunderbird (nl)
|
|
229
|
-
/^\s*Do\s?:(.+)$/m, // Apple Mail (pl), New Outlook 2019 (pl)
|
|
232
|
+
/^\s*A\s?:(.+)$/m, // Apple Mail (it), New Outlook 2019 (it), Thunderbird (it), HubSpot (es, it)
|
|
233
|
+
/^\s*Aan\s?:(.+)$/m, // Apple Mail (nl), New Outlook 2019 (nl), Thunderbird (nl), HubSpot (nl)
|
|
234
|
+
/^\s*Do\s?:(.+)$/m, // Apple Mail (pl), New Outlook 2019 (pl), HubSpot (pl)
|
|
230
235
|
/^\s*Destinatarul\s?:(.+)$/m, // Apple Mail (ro)
|
|
231
236
|
/^\s*Кому\s?:(.+)$/m, // Apple Mail (ru, uk), New Outlook 2019 (ru), Thunderbird (ru, uk)
|
|
232
237
|
/^\s*Pre\s?:(.+)$/m, // Apple Mail (sk), Thunderbird (sk)
|
|
233
238
|
/^\s*Till\s?:(.+)$/m, // Apple Mail (sv), New Outlook 2019 (sv), Thunderbird (sv)
|
|
234
239
|
/^\s*Kime\s?:(.+)$/m, // Apple Mail (tr), Thunderbird (tr)
|
|
235
240
|
/^\s*Pour\s?:(.+)$/m, // Thunderbird (fr)
|
|
236
|
-
/^\s*Adresat\s?:(.+)$/m // Thunderbird (pl)
|
|
241
|
+
/^\s*Adresat\s?:(.+)$/m, // Thunderbird (pl)
|
|
242
|
+
/^\s*送信先:(.+)$/m // HubSpot (ja)
|
|
237
243
|
],
|
|
238
244
|
|
|
239
245
|
original_to_lax : [
|
|
@@ -278,22 +284,23 @@ var REGEXES = {
|
|
|
278
284
|
],
|
|
279
285
|
|
|
280
286
|
original_cc : [
|
|
281
|
-
/^\*?\s*Cc\s?:\*?(.+)$/m, // Apple Mail (en, da, es, fr, hr, it, pt, pt-br, ro, sk), Gmail (all locales), Outlook Live / 365 (all locales), New Outlook 2019 (da, de, en, fr, it, pt-br), Missive (en)
|
|
287
|
+
/^\*?\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)
|
|
282
288
|
/^\s*CC\s?:(.+)$/m, // New Outlook 2019 (es, nl, pt), Thunderbird (da, en, es, fi, hr, hu, it, nl, no, pt, pt-br, ro, tr, uk)
|
|
283
289
|
/^\s*Kopie\s?:(.+)$/m, // Apple Mail (cs, de, nl), New Outlook 2019 (cs), Thunderbird (cs)
|
|
284
|
-
/^\s*Kopio\s?:(.+)$/m, // Apple Mail (fi), New Outlook 2019 (
|
|
290
|
+
/^\s*Kopio\s?:(.+)$/m, // Apple Mail (fi), New Outlook 2019 (fi), HubSpot (fi)
|
|
285
291
|
/^\s*Másolat\s?:(.+)$/m, // Apple Mail (hu)
|
|
286
292
|
/^\s*Kopi\s?:(.+)$/m, // Apple Mail (no)
|
|
287
293
|
/^\s*Dw\s?:(.+)$/m, // Apple Mail (pl)
|
|
288
294
|
/^\s*Копия\s?:(.+)$/m, // Apple Mail (ru), New Outlook 2019 (ru), Thunderbird (ru)
|
|
289
|
-
/^\s*Kopia\s?:(.+)$/m, // Apple Mail (sv), New Outlook 2019 (sv), Thunderbird (pl, sv)
|
|
295
|
+
/^\s*Kopia\s?:(.+)$/m, // Apple Mail (sv), New Outlook 2019 (sv), Thunderbird (pl, sv), HubSpot (sv)
|
|
290
296
|
/^\s*Bilgi\s?:(.+)$/m, // Apple Mail (tr)
|
|
291
297
|
/^\s*Копія\s?:(.+)$/m, // Apple Mail (uk),
|
|
292
298
|
/^\s*Másolatot kap\s?:(.+)$/m, // New Outlook 2019 (hu)
|
|
293
299
|
/^\s*Kópia\s?:(.+)$/m, // New Outlook 2019 (sk), Thunderbird (sk)
|
|
294
|
-
/^\s*DW\s?:(.+)$/m, // New Outlook 2019 (pl)
|
|
300
|
+
/^\s*DW\s?:(.+)$/m, // New Outlook 2019 (pl), HubSpot (pl)
|
|
295
301
|
/^\s*Kopie \(CC\)\s?:(.+)$/m, // Thunderbird (de)
|
|
296
|
-
/^\s*Copie à\s?:(.+)$/m // Thunderbird (fr)
|
|
302
|
+
/^\s*Copie à\s?:(.+)$/m, // Thunderbird (fr)
|
|
303
|
+
/^\s*CC:(.+)$/m // HubSpot (ja)
|
|
297
304
|
],
|
|
298
305
|
|
|
299
306
|
original_cc_lax : [
|
|
@@ -311,18 +318,19 @@ var REGEXES = {
|
|
|
311
318
|
],
|
|
312
319
|
|
|
313
320
|
original_date : [
|
|
314
|
-
/^\s*Date\s?:(.+)$/m, // Apple Mail (en, fr), Gmail (all locales), New Outlook 2019 (en, fr), Thunderbird (da, en, fr), Missive (en)
|
|
315
|
-
/^\s*Datum\s?:(.+)$/m, // Apple Mail (cs, de, hr, nl, sv), New Outlook 2019 (cs, de, nl, sv), Thunderbird (cs, de, hr, nl, sv)
|
|
321
|
+
/^\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)
|
|
322
|
+
/^\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)
|
|
316
323
|
/^\s*Dato\s?:(.+)$/m, // Apple Mail (da, no), New Outlook 2019 (da), Thunderbird (no)
|
|
317
|
-
/^\s*Fecha\s?:(.+)$/m, // Apple Mail (es), New Outlook 2019 (es), Thunderbird (es)
|
|
318
|
-
/^\s*Päivämäärä\s?:(.+)$/m, // Apple Mail (fi), New Outlook 2019 (fi)
|
|
324
|
+
/^\s*Fecha\s?:(.+)$/m, // Apple Mail (es), New Outlook 2019 (es), Thunderbird (es), HubSpot (es)
|
|
325
|
+
/^\s*Päivämäärä\s?:(.+)$/m, // Apple Mail (fi), New Outlook 2019 (fi), HubSpot (fi)
|
|
319
326
|
/^\s*Dátum\s?:(.+)$/m, // Apple Mail (hu, sk), New Outlook 2019 (sk), Thunderbird (hu, sk)
|
|
320
|
-
/^\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)
|
|
327
|
+
/^\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)
|
|
321
328
|
/^\s*Dată\s?:(.+)$/m, // Apple Mail (ro), Thunderbird (ro)
|
|
322
329
|
/^\s*Дата\s?:(.+)$/m, // Apple Mail (ru, uk), New Outlook 2019 (ru), Thunderbird (ru, uk)
|
|
323
330
|
/^\s*Tarih\s?:(.+)$/m, // Apple Mail (tr), Thunderbird (tr)
|
|
324
331
|
/^\*?\s*Sent\s?:\*?(.+)$/m, // Outlook Live / 365 (all locales)
|
|
325
|
-
/^\s*Päiväys\s?:(.+)$/m // Thunderbird (fi)
|
|
332
|
+
/^\s*Päiväys\s?:(.+)$/m, // Thunderbird (fi)
|
|
333
|
+
/^\s*日付:(.+)$/m // HubSpot (ja)
|
|
326
334
|
],
|
|
327
335
|
|
|
328
336
|
original_date_lax : [
|
|
@@ -411,6 +419,9 @@ class Parser {
|
|
|
411
419
|
// Remove Byte Order Mark
|
|
412
420
|
_body = _body.replace(this.__regexes.byte_order_mark, "");
|
|
413
421
|
|
|
422
|
+
// Replace Non-breaking space with regular space
|
|
423
|
+
_body = _body.replace(this.__regexes.non_breaking_space, " ");
|
|
424
|
+
|
|
414
425
|
// First method: split via the separator (Apple Mail, Gmail, \
|
|
415
426
|
// Outlook Live / 365, Outlook 2019, Yahoo Mail, Thunderbird)
|
|
416
427
|
var _match = loopRegexes(this.__regexes.separator, _body, "split");
|
|
@@ -463,7 +474,7 @@ class Parser {
|
|
|
463
474
|
var _text = text.replace(this.__regexes.byte_order_mark, "");
|
|
464
475
|
|
|
465
476
|
// Remove ">" at the beginning of each line, while keeping line breaks
|
|
466
|
-
_text =
|
|
477
|
+
_text = _text.replace(this.__regexes.quote_line_break, "");
|
|
467
478
|
|
|
468
479
|
// Remove ">" at the beginning of other lines
|
|
469
480
|
_text = _text.replace(this.__regexes.quote, "");
|
|
@@ -529,7 +540,7 @@ class Parser {
|
|
|
529
540
|
|
|
530
541
|
// A new line must be present between the Cc, To, Reply-To or Subject \
|
|
531
542
|
// part and the actual body
|
|
532
|
-
if (_match && _match.length
|
|
543
|
+
if (_match && _match.length >= 3 && _match[2].startsWith("\n\n")) {
|
|
533
544
|
return trimString(_match[2]);
|
|
534
545
|
}
|
|
535
546
|
}
|
package/lib/utils.js
CHANGED
|
@@ -13,12 +13,15 @@ var RE2 = require("re2");
|
|
|
13
13
|
/**
|
|
14
14
|
* Executes multiple regular expressions until one succeeds
|
|
15
15
|
* @public
|
|
16
|
-
* @param {object}
|
|
17
|
-
* @param {string}
|
|
18
|
-
* @param {string}
|
|
19
|
-
* @
|
|
16
|
+
* @param {object} regexes
|
|
17
|
+
* @param {string} str
|
|
18
|
+
* @param {string} [mode]
|
|
19
|
+
* @param {boolean} [highestPosition]
|
|
20
|
+
* @return {object} The result of the first successfull regular expression
|
|
20
21
|
*/
|
|
21
|
-
var loopRegexes = function(
|
|
22
|
+
var loopRegexes = function(
|
|
23
|
+
regexes, str, mode = "match", highestPosition = true
|
|
24
|
+
) {
|
|
22
25
|
var _match;
|
|
23
26
|
|
|
24
27
|
for (var _i = 0; _i < regexes.length; _i++) {
|
|
@@ -29,11 +32,13 @@ var loopRegexes = function(regexes, str, mode = "match") {
|
|
|
29
32
|
_regex = new RE2(regexes[_i]);
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
var _currentMatch = (
|
|
33
36
|
_regex[mode](str || "", mode === "replace" ? "" : undefined)
|
|
34
37
|
);
|
|
35
38
|
|
|
36
39
|
if (mode === "replace") {
|
|
40
|
+
_match = _currentMatch;
|
|
41
|
+
|
|
37
42
|
// A successfull replace must return a smaller string than the input
|
|
38
43
|
var _maxLength = str.length;
|
|
39
44
|
|
|
@@ -44,8 +49,36 @@ var loopRegexes = function(regexes, str, mode = "match") {
|
|
|
44
49
|
// A successfull split must return an array with at least two items
|
|
45
50
|
var _minLength = mode === "split" ? 1 : 0;
|
|
46
51
|
|
|
47
|
-
if ((
|
|
48
|
-
|
|
52
|
+
if ((_currentMatch || []).length > _minLength) {
|
|
53
|
+
if (highestPosition === true) {
|
|
54
|
+
// No previous match?
|
|
55
|
+
if (!_match) {
|
|
56
|
+
// Save match and continue looking for other matches
|
|
57
|
+
_match = _currentMatch;
|
|
58
|
+
} else {
|
|
59
|
+
var _higher;
|
|
60
|
+
|
|
61
|
+
if (mode === "match") {
|
|
62
|
+
_higher = _match.index > _currentMatch.index;
|
|
63
|
+
} else if (mode === "split") {
|
|
64
|
+
_higher = (
|
|
65
|
+
_match.length === _currentMatch.length &&
|
|
66
|
+
_match[0].length > _currentMatch[0].length
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Match higher positioned than previous one?
|
|
71
|
+
if (_higher) {
|
|
72
|
+
// Replace match and continue looking for other matches
|
|
73
|
+
_match = _currentMatch;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
// Save match and stop
|
|
78
|
+
_match = _currentMatch;
|
|
79
|
+
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
49
82
|
}
|
|
50
83
|
}
|
|
51
84
|
}
|