From 57f72e3540397ee0801abd4aabd14ef9a5cc5424 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 18 Jul 2018 14:36:47 +0100 Subject: [PATCH] [Minor] Fix phishing maps logic --- src/plugins/lua/phishing.lua | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/plugins/lua/phishing.lua b/src/plugins/lua/phishing.lua index 69aec219f..3f81cd036 100644 --- a/src/plugins/lua/phishing.lua +++ b/src/plugins/lua/phishing.lua @@ -228,27 +228,40 @@ local function phishing_map(mapname, phishmap, id) else xd[1] = opts[mapname] end + + local found_maps = {} + for _,d in ipairs(xd) do local s = string.find(d, ':[^:]+$') if s then local sym = string.sub(d, s + 1, -1) local map = string.sub(d, 1, s - 1) - rspamd_config:register_virtual_symbol(sym, 1, id) - local rmap = rspamd_config:add_map ({ - type = 'set', - url = map, - description = 'Phishing ' .. mapname .. ' map', - }) - if rmap then - local rule = {symbol = sym, map = rmap} - table.insert(phishmap, rule) + + if found_maps[sym] then + table.insert(found_maps[sym], map) else - rspamd_logger.infox(rspamd_config, 'cannot add map: ' .. map .. ' for symbol: ' .. sym) + found_maps[sym] = {map} end else rspamd_logger.infox(rspamd_config, mapname .. ' option must be in format :') end end + + for sym,urls in pairs(found_maps) do + local rmap = rspamd_config:add_map ({ + type = 'set', + url = urls, + description = 'Phishing ' .. mapname .. ' map', + }) + if rmap then + rspamd_config:register_virtual_symbol(sym, 1, id) + local rule = {symbol = sym, map = rmap} + table.insert(phishmap, rule) + else + rspamd_logger.infox(rspamd_config, 'cannot add map: %s for symbol: %s', + table.concat(urls, ";"), sym) + end + end end end -- 2.39.5