commit 0d69dbb: [Project] Dmarc: Fix munging logic
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Mar 24 11:00:06 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-03-24 10:51:11 +0000
URL: https://github.com/rspamd/rspamd/commit/0d69dbb1a454af7fd1e75b2e54001399773f6a4f (HEAD -> master)
[Project] Dmarc: Fix munging logic
---
src/plugins/lua/dmarc.lua | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua
index 4276f2bd6..b6174c093 100644
--- a/src/plugins/lua/dmarc.lua
+++ b/src/plugins/lua/dmarc.lua
@@ -1558,37 +1558,42 @@ if opts.munging then
end
from = from[1]
- local via_name = rcpt_found.user
+ local via_user = rcpt_found.user
local via_addr = rcpt_found.addr
+ local via_name
if from.name then
- from.name = string.format('%s via %s', from.name, via_name)
+ via_name = string.format('%s via %s', from.name, via_user)
else
- from.name = string.format('%s via %s', from.user or 'unknown', via_name)
+ via_name = string.format('%s via %s', from.user or 'unknown', via_user)
end
local hdr_encoded = rspamd_util.fold_header('From',
rspamd_util.mime_header_encode(string.format('%s <%s>',
- from.name, via_addr)))
+ via_name, via_addr)))
+ local orig_from_encoded = rspamd_util.fold_header('X-Original-From',
+ rspamd_util.mime_header_encode(string.format('%s <%s>',
+ from.name or '', from.addr)))
local add_hdrs = {
['From'] = { order = 1, value = hdr_encoded },
}
if munging_opts.reply_goes_to_list then
- -- Add another reply-to
+ -- Reply-to goes to the list
table.insert(add_hdrs['Reply-To'], {order = 0, value = via_addr})
- add_hdrs['X-Original-From'] = { order = 0, value = hdr_encoded}
else
- add_hdrs['Reply-To'] = {order = 0, value = via_addr}
+ add_hdrs['Reply-To'] = {order = 0, value = from.addr}
end
+
+ add_hdrs['X-Original-From'] = { order = 0, value = orig_from_encoded}
lua_mime.modify_headers(task, {
remove = {['From'] = {0}},
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.domain)
- task:insert_result('DMARC_MUNGED', 1.0, from.domain)
+ rspamd_logger.infox(task, 'munged DMARC header for %s', from.addr)
+ task:insert_result('DMARC_MUNGED', 1.0, from.addr)
end
rspamd_config:register_symbol({
More information about the Commits
mailing list