]> source.dussan.org Git - rspamd.git/commitdiff
[Rules] Fix FPs for CTYPE_MIXED_BOGUS
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 11 Apr 2021 20:13:42 +0000 (21:13 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 11 Apr 2021 20:13:42 +0000 (21:13 +0100)
rules/headers_checks.lua

index c4e4a4a678436a067eaf42ced8c5b8dc63c7dc24..79b8e5c2f3db53a2771381759c8d2d2a66c91c32 100644 (file)
@@ -1004,14 +1004,19 @@ rspamd_config.CTYPE_MIXED_BOGUS = {
     if (not ct:lower():match('^multipart/mixed')) then return false end
     local found = false
     -- Check each part and look for a part that isn't multipart/* or text/plain or text/html
+    local ntext_parts = 0
     for _,p in ipairs(parts) do
-      local pct = p:get_header('Content-Type')
-      if (pct) then
-        pct = pct:lower()
-        if not ((pct:match('^multipart/') or
-            pct:match('^text/plain') or
-            pct:match('^text/html'))) then
+      local mtype,_ = p:get_type()
+      if mtype then
+        if mtype == 'text' then
+          ntext_parts = ntext_parts + 1
+          if ntext_parts > 2 then
+            found = true
+            break
+          end
+        elseif mtype ~= 'multipart' then
           found = true
+          break
         end
       end
     end