From: Vsevolod Stakhov Date: Tue, 7 Mar 2017 11:48:48 +0000 (+0000) Subject: [Fix] Fix MISSING_MIME_VERSION rule for plain messages X-Git-Tag: 1.5.2~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=207375a0f80a29ca6aac64a0b2f164fd39ac2799;p=rspamd.git [Fix] Fix MISSING_MIME_VERSION rule for plain messages --- diff --git a/rules/misc.lua b/rules/misc.lua index 28fb19f5c..151500d88 100644 --- a/rules/misc.lua +++ b/rules/misc.lua @@ -716,13 +716,15 @@ local check_mime_id = rspamd_config:register_callback_symbol('CHECK_MIME', 1.0, -- Make sure there is a MIME-Version header local mv = task:get_header('MIME-Version') + local missing_mime = false if (not mv) then - task:insert_result('MISSING_MIME_VERSION', 1.0) + missing_mime = true end local found_ma = false local found_plain = false local found_html = false + local cte_7bit = false for _,p in ipairs(parts) do local mtype,subtype = p:get_type() @@ -731,13 +733,27 @@ local check_mime_id = rspamd_config:register_callback_symbol('CHECK_MIME', 1.0, found_ma = true end if (ctype == 'text/plain') then + if p:get_cte() == '7bit' then + cte_7bit = true + end found_plain = true end if (ctype == 'text/html') then + if p:get_cte() == '7bit' then + cte_7bit = true + end found_html = true end end + if missing_mime then + if not found_ma and ((found_plain or found_html) and cte_7bit) then + -- Skip symbol insertion + else + task:insert_result('MISSING_MIME_VERSION', 1.0) + end + end + if (found_ma) then if (not found_plain) then task:insert_result('MIME_MA_MISSING_TEXT', 1.0)