From: Vsevolod Stakhov Date: Mon, 9 Apr 2018 11:11:21 +0000 (+0100) Subject: [Fix] Fix weights of dynamic squeezed rules X-Git-Tag: 1.7.3~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=498a8112a11c8b622010dae023e13017e8748be1;p=rspamd.git [Fix] Fix weights of dynamic squeezed rules --- diff --git a/lualib/lua_squeeze_rules.lua b/lualib/lua_squeeze_rules.lua index ef098a2d3..dd68ccb61 100644 --- a/lualib/lua_squeeze_rules.lua +++ b/lualib/lua_squeeze_rules.lua @@ -42,20 +42,41 @@ local function gen_lua_squeeze_function(order) if first then table.remove(ret, 1) - if type(ret[1]) == 'table' then - task:insert_result(sym, 1.0, ret[1]) + local second = ret[2] + + if type(second) == 'number' then + table.remove(ret, 1) + if second ~= 0 then + if type(ret[1]) == 'table' then + task:insert_result(sym, second, ret[1]) + else + task:insert_result(sym, second, ret) + end + end else - task:insert_result(sym, 1.0, ret) + if type(ret[1]) == 'table' then + task:insert_result(sym, 1.0, ret[1]) + else + task:insert_result(sym, 1.0, ret) + end end end elseif type(first) == 'number' then table.remove(ret, 1) if first ~= 0 then - task:insert_result(sym, first, ret) + if type(ret[1]) == 'table' then + task:insert_result(sym, first, ret[1]) + else + task:insert_result(sym, first, ret) + end end else - task:insert_result(sym, 1.0, ret) + if type(ret[1]) == 'table' then + task:insert_result(sym, 1.0, ret[1]) + else + task:insert_result(sym, 1.0, ret) + end end end else