Skip to content

Commit be24af0

Browse files
authored
fix(addressregister): Do not add no-reply addresses to the addressregister ZMS-99 (#551)
* add check for noreply and no-reply in the email * add check for disallowed headers * use case insensitive regex instead of hardcoded values
1 parent fd98244 commit be24af0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/message-handler.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const { SettingsHandler } = require('./settings-handler');
1919

2020
// index only the following headers for SEARCH
2121
const INDEXED_HEADERS = ['to', 'cc', 'subject', 'from', 'sender', 'reply-to', 'message-id', 'thread-index', 'list-id', 'delivered-to'];
22+
const DISALLOWED_HEADERS_FOR_ADDRESS_REGISTER = ['list-id', 'auto-submitted', 'x-auto-response-suppress'];
2223

2324
openpgp.config.commentstring = 'Plaintext message encrypted by WildDuck Mail Server';
2425
openpgp.config.versionString = `WildDuck v${packageData.version}`;
@@ -525,9 +526,21 @@ class MessageHandler {
525526

526527
if (parsed) {
527528
let keyList = mailboxData.specialUse === '\\Sent' ? ['to', 'cc', 'bcc'] : ['from'];
529+
530+
for (const disallowedHeader of DISALLOWED_HEADERS_FOR_ADDRESS_REGISTER) {
531+
// if email contains headers that we do not want,
532+
// don't add any emails to address register
533+
if (parsed[disallowedHeader]) {
534+
return next();
535+
}
536+
}
537+
528538
for (let key of keyList) {
529539
if (parsed[key] && parsed[key].length) {
530540
for (let addr of parsed[key]) {
541+
if (/no-?reply/i.test(addr.address)) {
542+
continue;
543+
}
531544
if (!addresses.some(a => a.address === addr.address)) {
532545
addresses.push(addr);
533546
}

0 commit comments

Comments
 (0)