]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix weights of dynamic squeezed rules
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 9 Apr 2018 11:11:21 +0000 (12:11 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 9 Apr 2018 11:11:21 +0000 (12:11 +0100)
lualib/lua_squeeze_rules.lua

index ef098a2d3597489a71f0c3628269c07b59e05209..dd68ccb61ca72fba91c0cfc1af6c329bcc259512 100644 (file)
@@ -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