Skip to content

Commit

Permalink
fix(addressregister): Do not add no-reply addresses to the addressreg…
Browse files Browse the repository at this point in the history
…ister 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
  • Loading branch information
NickOvt committed Nov 30, 2023
1 parent fd98244 commit be24af0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/message-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const { SettingsHandler } = require('./settings-handler');

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

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

if (parsed) {
let keyList = mailboxData.specialUse === '\\Sent' ? ['to', 'cc', 'bcc'] : ['from'];

for (const disallowedHeader of DISALLOWED_HEADERS_FOR_ADDRESS_REGISTER) {
// if email contains headers that we do not want,
// don't add any emails to address register
if (parsed[disallowedHeader]) {
return next();
}
}

for (let key of keyList) {
if (parsed[key] && parsed[key].length) {
for (let addr of parsed[key]) {
if (/no-?reply/i.test(addr.address)) {
continue;
}
if (!addresses.some(a => a.address === addr.address)) {
addresses.push(addr);
}
Expand Down

0 comments on commit be24af0

Please sign in to comment.