aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_magic/init.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-07 16:37:58 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-07 16:37:58 +0100
commit7cf7a889a60efb651fdf2062b1773ad17c9eec7f (patch)
tree6368edc14698bfdea8cd3a59bc7c55ca653bf511 /lualib/lua_magic/init.lua
parent9dc510171d0a7f308697b70ab22bfe5dafbf29a5 (diff)
downloadrspamd-7cf7a889a60efb651fdf2062b1773ad17c9eec7f.tar.gz
rspamd-7cf7a889a60efb651fdf2062b1773ad17c9eec7f.zip
[Project] Lua_magic: Add mime parts detection function
Diffstat (limited to 'lualib/lua_magic/init.lua')
-rw-r--r--lualib/lua_magic/init.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/lualib/lua_magic/init.lua b/lualib/lua_magic/init.lua
index 59e2a6e36..8b5064bfe 100644
--- a/lualib/lua_magic/init.lua
+++ b/lualib/lua_magic/init.lua
@@ -21,6 +21,7 @@ limitations under the License.
local patterns = require "lua_magic/patterns"
local types = require "lua_magic/types"
+local heuristics = require "lua_magic/heuristics"
local fun = require "fun"
local lua_util = require "lua_util"
@@ -317,6 +318,16 @@ exports.detect = function(input, log_obj)
return nil
end
+exports.detect_mime_part = function(part, log_obj)
+ local ext,weight = heuristics.mime_part_heuristic(part)
+
+ if ext and weight and weight > 20 then
+ return ext,types[ext]
+ end
+
+ return exports.detect(part:get_content(), log_obj)
+end
+
-- This parameter specifies how many bytes are checked in the input
-- Rspamd checks 2 chunks at start and 1 chunk at the end
exports.chunk_size = 32768