]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix MISSING_MIME_VERSION rule for plain messages
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 7 Mar 2017 11:48:48 +0000 (11:48 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 7 Mar 2017 11:49:17 +0000 (11:49 +0000)
rules/misc.lua

index 28fb19f5cf78decfd39c3b4d8cefa17407c994d9..151500d886ba990fb115084dcde9b5413919fb5e 100644 (file)
@@ -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)