From: Vsevolod Stakhov Date: Fri, 27 Sep 2019 10:05:39 +0000 (+0100) Subject: [Feature] Multimap: Allow multiple email addresses matches X-Git-Tag: 2.0~116 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=71246a1a926cc088de211b5a87a6ed5eacd87270;p=rspamd.git [Feature] Multimap: Allow multiple email addresses matches --- diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index 284a05198..bafa27476 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -235,27 +235,27 @@ local function apply_addr_filter(task, filter, input, rule) if filter == 'email:addr' or filter == 'email' then local addr = util.parse_mail_address(input, task:get_mempool()) if addr and addr[1] then - return addr[1]['addr'] + return fun.totable(fun.map(function(a) return a.addr end, addr)) end elseif filter == 'email:user' then local addr = util.parse_mail_address(input, task:get_mempool()) if addr and addr[1] then - return addr[1]['user'] + return fun.totable(fun.map(function(a) return a.user end, addr)) end elseif filter == 'email:domain' then local addr = util.parse_mail_address(input, task:get_mempool()) if addr and addr[1] then - return addr[1]['domain'] + return fun.totable(fun.map(function(a) return a.domain end, addr)) end elseif filter == 'email:domain:tld' then local addr = util.parse_mail_address(input, task:get_mempool()) if addr and addr[1] then - return util.get_tld(addr[1]['domain']) + return fun.totable(fun.map(function(a) return util.get_tld(a.domain) end, addr)) end elseif filter == 'email:name' then local addr = util.parse_mail_address(input, task:get_mempool()) if addr and addr[1] then - return addr[1]['name'] + return fun.totable(fun.map(function(a) return a.name end, addr)) end elseif filter == 'ip_addr' then local ip_addr = rspamd_ip.from_string(input) @@ -637,7 +637,11 @@ local function multimap_callback(task, rule) end end - match_element(r, value, rule_callback) + if type(value) == 'table' then + fun.each(function(elt) match_element(r, elt, rule_callback) end, value) + else + match_element(r, value, rule_callback) + end end -- Match list of values according to the field