From: Alexander Moisseev Date: Mon, 19 Sep 2016 13:38:46 +0000 (+0400) Subject: [Fix] mid: fix map initialization X-Git-Tag: 1.4.0~407^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3392924d2a310d902192bd272544cef4d929e59b;p=rspamd.git [Fix] mid: fix map initialization --- diff --git a/src/plugins/lua/mid.lua b/src/plugins/lua/mid.lua index b449746f9..79ed35151 100644 --- a/src/plugins/lua/mid.lua +++ b/src/plugins/lua/mid.lua @@ -33,7 +33,7 @@ local settings = { csymbol_missing_mid_allowed = 'MISSING_MID_ALLOWED', } -local maps = {} +local map = {} local function known_mid_cb(task) local re = {} @@ -41,22 +41,20 @@ local function known_mid_cb(task) local das = task:get_symbol(settings['symbol_dkim_allow']) if das and das[1] and das[1]['options'] then for _,dkim_domain in ipairs(das[1]['options']) do - for _,map in ipairs(maps) do - local v = map:get_key(dkim_domain) - if v then - if v == '' then - if not header then - task:insert_result(settings['symbol_known_no_mid'], 1, dkim_domain) + local v = map:get_key(dkim_domain) + if v then + if v == '' then + if not header then + task:insert_result(settings['symbol_known_no_mid'], 1, dkim_domain) + return + end + else + re[dkim_domain] = rspamd_regexp.create_cached(v) + if header then + if re[dkim_domain]:match(header) then + task:insert_result(settings['symbol_known_mid'], 1, dkim_domain) return end - else - re[dkim_domain] = rspamd_regexp.create_cached(v) - if header then - if re[dkim_domain]:match(header) then - task:insert_result(settings['symbol_known_mid'], 1, dkim_domain) - return - end - end end end end @@ -71,19 +69,11 @@ if opts then end if settings['url'] and #settings['url'] > 0 then - local urls = {} - if type(settings['url']) == 'table' then - urls = settings['url'] - else - urls[1] = settings['url'] - end - for i,u in ipairs(urls) do - maps[i] = rspamd_config:add_map ({ - url = u, - type = 'map', - description = 'Message-IDs map' - }) - end + map = rspamd_config:add_map ({ + url = settings['url'], + type = 'map', + description = 'Message-IDs map' + }) local id = rspamd_config:register_symbol({ name = 'KNOWN_MID_CALLBACK',