From: Vsevolod Stakhov Date: Fri, 2 Apr 2021 12:18:58 +0000 (+0100) Subject: [Minor] DMARC: Fix munging when reply-to is presented X-Git-Tag: 3.0~531 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cbbf468810225cc330b21d35c1b2e11108e44156;p=thirdparty%2Frspamd.git [Minor] DMARC: Fix munging when reply-to is presented --- diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index cb5a585022..8ecf51ec77 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -1577,19 +1577,33 @@ if opts.munging then local add_hdrs = { ['From'] = { order = 1, value = hdr_encoded }, } + local remove_hdrs = { + {['From'] = 0}, + } + local nreply = from.addr if munging_opts.reply_goes_to_list then -- Reply-to goes to the list - table.insert(add_hdrs['Reply-To'], {order = 0, value = via_addr}) - else - add_hdrs['Reply-To'] = {order = 0, value = from.addr} + nreply = via_addr end + if task:has_header('Reply-To') then + -- If we have reply-to header, then we need to insert an additional + -- address there + local orig_reply = task:get_header_full('Reply-To')[1] + if orig_reply.value then + nreply = string.format('%s, %s', orig_reply.value, nreply) + end + remove_hdrs['Reply-To'] = 1 + end + + add_hdrs['Reply-To'] = {order = 0, value = nreply} + add_hdrs['X-Original-From'] = { order = 0, value = orig_from_encoded} lua_mime.modify_headers(task, { - remove = {['From'] = 0}, + remove = remove_hdrs, add = add_hdrs - }) + }) lua_util.debugm(N, task, 'munged DMARC header for %s: %s -> %s', from.domain, hdr_encoded, from.addr) rspamd_logger.infox(task, 'munged DMARC header for %s', from.addr)