]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Add some logic to use mime_types tracking in fuzzy checks
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 6 Nov 2018 12:07:49 +0000 (12:07 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 6 Nov 2018 12:07:49 +0000 (12:07 +0000)
lualib/lua_fuzzy.lua

index fadf4fa6ab4024a91d07b18bf4dc99f8a0341e06..e18f466a8a5f73258358f23a2afac1cead4bf6d9 100644 (file)
@@ -204,12 +204,29 @@ local function mime_types_check(task, part, rule)
   if not t then return false, false end
 
   local ct = string.format('%s/%s', t, st)
+  local id = part:get_id()
+
+  -- For bad mime mime parts we implicitly enable fuzzy check
+  local mime_trace = task:get_symbol('MIME_TRACE')
+  local opts = {}
+
+  if mime_trace then
+    opts = mime_trace.options
+  end
+  opts = fun.tomap(fun.map(function(opt)
+    local elts = lua_util.str_split(opt, ':')
+    return elts[1],elts[2]
+  end, opts))
+
+  if opts[id] and opts[id] == '-' then
+    return check_length(task, part, rule),false
+  end
 
   if rule.mime_types then
     if fun.any(function(gl_re)
       if gl_re:match(ct) then return true else return false end
     end, rule.mime_types) then
-      return true, true
+      return check_length(task, part, rule),false
     end
 
     return false, false