diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-11-06 12:07:49 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-11-06 12:07:49 +0000 |
commit | 2537b34b8a3c2e784d9ea7b999fb14464f91e357 (patch) | |
tree | 612f91b860ec9021a308c21fef4e7039f28ae454 /lualib | |
parent | b27fdf29b65e24ea775bfe1471c7adc1624b7f92 (diff) | |
download | rspamd-2537b34b8a3c2e784d9ea7b999fb14464f91e357.tar.gz rspamd-2537b34b8a3c2e784d9ea7b999fb14464f91e357.zip |
[Minor] Add some logic to use mime_types tracking in fuzzy checks
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_fuzzy.lua | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lualib/lua_fuzzy.lua b/lualib/lua_fuzzy.lua index fadf4fa6a..e18f466a8 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 |