From: Vsevolod Stakhov Date: Tue, 6 Nov 2018 12:07:49 +0000 (+0000) Subject: [Minor] Add some logic to use mime_types tracking in fuzzy checks X-Git-Tag: 1.8.2~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2537b34b8a3c2e784d9ea7b999fb14464f91e357;p=thirdparty%2Frspamd.git [Minor] Add some logic to use mime_types tracking in fuzzy checks --- diff --git a/lualib/lua_fuzzy.lua b/lualib/lua_fuzzy.lua index fadf4fa6ab..e18f466a8a 100644 --- a/lualib/lua_fuzzy.lua +++ b/lualib/lua_fuzzy.lua @@ -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