From 5d3677f48bf7b0493bab5cae6f7928f9a878f320 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 4 Jul 2018 14:56:47 +0100 Subject: [Minor] Use proper hashing when getting texts fuzzy hash --- lualib/rspamadm/mime.lua | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'lualib/rspamadm') diff --git a/lualib/rspamadm/mime.lua b/lualib/rspamadm/mime.lua index f31fe29f1..f41529646 100644 --- a/lualib/rspamadm/mime.lua +++ b/lualib/rspamadm/mime.lua @@ -325,12 +325,22 @@ local function stat_handler(opts) end for _,part in ipairs(parts) do if not part:is_multipart() then - table.insert(out_elts[fname], { - digest = part:get_digest(), - file = part:get_filename(), - type = string.format('%s/%s', part:get_type()) - }) - + local text = part:get_text() + + if text then + local digest,shingles = text:get_fuzzy_hashes(task:get_mempool()) + table.insert(out_elts[fname], { + digest = digest, + shingles = rspamd_logger.slog('%s', shingles), + type = string.format('%s/%s', part:get_type()) + }) + else + table.insert(out_elts[fname], { + digest = part:get_digest(), + file = part:get_filename(), + type = string.format('%s/%s', part:get_type()) + }) + end end end end -- cgit v1.2.3