From 90032f6bf20798a01a42fac9d436e3a73beb015d Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Wed, 5 Oct 2016 16:12:22 +0200 Subject: [PATCH] [Fix] Try avoid false-positives in HEADER_FORGED_MDN rule Issue: #621 Reported by: @AdUser --- rules/misc.lua | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/rules/misc.lua b/rules/misc.lua index fa06e142e..60277c409 100644 --- a/rules/misc.lua +++ b/rules/misc.lua @@ -220,6 +220,7 @@ rspamd_config.HEADER_RCONFIRM_MISMATCH = { rspamd_config.HEADER_FORGED_MDN = { callback = function (task) local mdn = task:get_header('Disposition-Notification-To') + if not mdn then return false end local header_rp = nil if task:has_from('smtp') then @@ -227,20 +228,21 @@ rspamd_config.HEADER_FORGED_MDN = { end -- Parse mail addr - local header_mdn = nil - if mdn then - local headers_mdn = util.parse_mail_address(mdn) - if headers_mdn then header_mdn = headers_mdn[1] end - end + local headers_mdn = util.parse_mail_address(mdn) - if header_mdn and not header_rp then return true end - if header_rp and not header_mdn then return false end + if headers_mdn and not header_rp then return true end + if header_rp and not headers_mdn then return false end + if not headers_mdn and not header_rp then return false end - if header_mdn and header_mdn['addr'] ~= header_rp['addr'] then - return true + local found_match = false + for _, h in ipairs(headers_mdn) do + if util.strequal_caseless(h['addr'], header_rp['addr']) then + found_match = true + break + end end - return false + return (not found_match) end, score = 2.0, -- 2.39.5