summaryrefslogtreecommitdiffstats
path: root/lualib/lua_fuzzy.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-12-11 12:26:36 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-12-11 12:26:36 +0000
commitc27548d3eb996dceb3a86a3ef1184249cee5fc40 (patch)
tree31212565e7b1cb88aa3deda1feef4c7c98bc33a5 /lualib/lua_fuzzy.lua
parent1912eac2d678b2993b4ef1fa41e36ca7a38e8239 (diff)
downloadrspamd-c27548d3eb996dceb3a86a3ef1184249cee5fc40.tar.gz
rspamd-c27548d3eb996dceb3a86a3ef1184249cee5fc40.zip
[Feature] Mime_types: Use detected content type as well
Diffstat (limited to 'lualib/lua_fuzzy.lua')
-rw-r--r--lualib/lua_fuzzy.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/lualib/lua_fuzzy.lua b/lualib/lua_fuzzy.lua
index 325a8ff6c..ea74b4131 100644
--- a/lualib/lua_fuzzy.lua
+++ b/lualib/lua_fuzzy.lua
@@ -241,6 +241,8 @@ local function mime_types_check(task, part, rule)
if not t then return false, false end
local ct = string.format('%s/%s', t, st)
+ t,st = part:get_detected_type()
+ local detected_ct = string.format('%s/%s', t, st)
local id = part:get_id()
lua_util.debugm(N, task, 'check binary part %s: %s', id, ct)
@@ -264,9 +266,14 @@ local function mime_types_check(task, part, rule)
if rule.mime_types then
if fun.any(function(gl_re)
- if gl_re:match(ct) then return true else return false end
+ if gl_re:match(ct) or (detected_ct and gl_re:match(detected_ct)) then
+ return true
+ else
+ return false
+ end
end, rule.mime_types) then
- lua_util.debugm(N, task, 'found mime type match for part %s: %s', id, ct)
+ lua_util.debugm(N, task, 'found mime type match for part %s: %s (%s detected)',
+ id, ct, detected_ct)
return check_length(task, part, rule),false
end