diff options
author | Andrew Lewis <nerf@judo.za.org> | 2016-10-05 16:12:22 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2016-10-05 16:12:22 +0200 |
commit | 90032f6bf20798a01a42fac9d436e3a73beb015d (patch) | |
tree | 3dc9cdd09440aea5d66a00471a4bbffb059bbcea /rules | |
parent | b89a7948754caad625bbe7208eab0ad3e8af1035 (diff) | |
download | rspamd-90032f6bf20798a01a42fac9d436e3a73beb015d.tar.gz rspamd-90032f6bf20798a01a42fac9d436e3a73beb015d.zip |
[Fix] Try avoid false-positives in HEADER_FORGED_MDN rule
Issue: #621
Reported by: @AdUser
Diffstat (limited to 'rules')
-rw-r--r-- | rules/misc.lua | 22 |
1 files 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, |