From: Vsevolod Stakhov Date: Wed, 18 Jul 2018 13:36:47 +0000 (+0100) Subject: [Minor] Fix phishing maps logic X-Git-Tag: 1.7.9~93 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=57f72e3540397ee0801abd4aabd14ef9a5cc5424;p=rspamd.git [Minor] Fix phishing maps logic --- 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