diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-12-11 12:26:36 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-12-11 12:26:36 +0000 |
commit | c27548d3eb996dceb3a86a3ef1184249cee5fc40 (patch) | |
tree | 31212565e7b1cb88aa3deda1feef4c7c98bc33a5 /src | |
parent | 1912eac2d678b2993b4ef1fa41e36ca7a38e8239 (diff) | |
download | rspamd-c27548d3eb996dceb3a86a3ef1184249cee5fc40.tar.gz rspamd-c27548d3eb996dceb3a86a3ef1184249cee5fc40.zip |
[Feature] Mime_types: Use detected content type as well
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/lua/mime_types.lua | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua index 9b82779d0..65b5524a7 100644 --- a/src/plugins/lua/mime_types.lua +++ b/src/plugins/lua/mime_types.lua @@ -911,6 +911,7 @@ local function check_mime_type(task) if parts then for _,p in ipairs(parts) do local mtype,subtype = p:get_type() + local dtype,dsubtype = p:get_detected_type() if not mtype then task:insert_result(settings['symbol_unknown'], 1.0, 'missing content type') @@ -920,6 +921,10 @@ local function check_mime_type(task) -- Check for attachment local filename = p:get_filename() local ct = string.format('%s/%s', mtype, subtype):lower() + local detected_ct + if dtype and dsubtype then + detected_ct = string.format('%s/%s', dtype, dsubtype) + end if filename then filename = filename:gsub('[^%s%g]', '?') @@ -971,13 +976,27 @@ local function check_mime_type(task) end if map then - local v = map:get_key(ct) + local v + local detected_different = false + if detected_ct and detected_ct ~= ct then + v = map:get_key(detected_ct) + detected_different = true + else + v = map:get_key(ct) + end if v then local n = tonumber(v) if n then if n > 0 then - task:insert_result(settings['symbol_bad'], n, ct) + if detected_different then + -- Penalize case + n = n * 1.5 + task:insert_result(settings['symbol_bad'], n, + string.format('%s:%s', ct, detected_ct)) + else + task:insert_result(settings['symbol_bad'], n, ct) + end task:insert_result('MIME_TRACE', 0.0, string.format("%s:%s", p:get_id(), '-')) elseif n < 0 then |