]> source.dussan.org Git - rspamd.git/commitdiff
[Rules] Penalise R_BAD_CTE_7BIT for utf8 messages
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 13 Jul 2017 18:18:12 +0000 (19:18 +0100)
committerAndrew Lewis <nerf@judo.za.org>
Mon, 28 Aug 2017 11:34:57 +0000 (13:34 +0200)
rules/misc.lua

index bc9b044eb20f473262b2c8e6c8f8886cd4e957e7..2e4d254185e2b2bc209bba29c295687ff5ed6232 100644 (file)
@@ -597,13 +597,26 @@ rspamd_config.R_BAD_CTE_7BIT = {
     for _,p in ipairs(tp) do
       local cte = p:get_mimepart():get_cte() or ''
       if cte ~= '8bit' and p:has_8bit_raw() then
-        return true,1.0,cte
+        local _,_,attrs = p:get_mimepart():get_type_full()
+        local mul = 1.0
+        local params = {cte}
+        if attrs then
+          print(attrs.charset)
+          if attrs.charset and attrs.charset:lower() == "utf-8" then
+            -- Penalise rule as people don't know that utf8 is surprisingly
+            -- eight bit encoding
+            mul = 0.3
+            table.insert(params, "utf8")
+          end
+        end
+
+        return true,mul,params
       end
     end
 
     return false
   end,
-  score = 4.0,
+  score = 3.5,
   description = 'Detects bad content-transfer-encoding for text parts',
   group = 'header'
 }