commit cbbf468: [Minor] DMARC: Fix munging when reply-to is presented

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Apr 2 12:21:05 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-04-02 13:18:58 +0100
URL: https://github.com/rspamd/rspamd/commit/cbbf468810225cc330b21d35c1b2e11108e44156 (HEAD -> master)

[Minor] DMARC: Fix munging when reply-to is presented

---
 src/plugins/lua/dmarc.lua | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua
index cb5a58502..8ecf51ec7 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)


More information about the Commits mailing list