]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Fix some more issues
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 17 Jun 2020 10:05:40 +0000 (11:05 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 17 Jun 2020 10:05:40 +0000 (11:05 +0100)
src/lua/lua_expression.c
test/lua/unit/expressions.lua

index b2addd30c571f7e81944afe80c7e9a32ab1f03a3..8c44eba081a81eeca4d8e9a7c035b59cfb208346 100644 (file)
@@ -352,7 +352,6 @@ lua_expr_create (lua_State *L)
        if (lua_type (L, 1) != LUA_TSTRING ||
                        (lua_type (L, 2) != LUA_TTABLE && lua_type (L, 2) != LUA_TFUNCTION) ||
                        rspamd_lua_check_mempool (L, 3) == NULL) {
-               msg_info ("bad arguments to lua_expr_create");
                lua_pushnil (L);
                lua_pushstring (L, "bad arguments");
        }
@@ -371,7 +370,7 @@ lua_expr_create (lua_State *L)
                        lua_gettable (L, -2);
 
                        if (lua_type (L, -1) != LUA_TFUNCTION) {
-                               lua_pop (L, 2);
+                               lua_pop (L, 1);
                                lua_pushnil (L);
                                lua_pushstring (L, "bad parse callback");
 
@@ -385,7 +384,7 @@ lua_expr_create (lua_State *L)
 
                        if (lua_type (L, -1) != LUA_TFUNCTION) {
                                if (lua_type (L, -1) != LUA_TNIL && lua_type (L, -1) != LUA_TNONE) {
-                                       lua_pop (L, 2);
+                                       lua_pop (L, 1);
                                        lua_pushnil (L);
                                        lua_pushstring (L, "bad process callback");
 
index 8633560ba838f8f0769855781e527680f66e9dd8..ce6c92dca35564d4b0b8cd86482d7f65b3ab4cc2 100644 (file)
@@ -48,10 +48,10 @@ context("Rspamd expressions", function()
     {'(((A))', nil},
     -- Balanced braces
     {'(((A)))', '(A)'},
-    -- Plus and comparison operators
-    {'A + B + C + D > 2', '2 (A) (B) (C) (D) +(4) >'},
+    -- Plus and comparison operators (after 2.6 this is not optimized, maybe we can return previous behaviour some day)
+    {'A + B + C + D > 2', '(A) (B) (C) (D) + + + 2 >'},
     -- Plus and logic operators
-    {'((A + B + C + D) > 2) & D', '(D) 2 (A) (B) (C) (D) +(4) > &'},
+    {'((A + B + C + D) > 2) & D', '(D) (A) (B) (C) (D) +(4) 2 > &'},
     -- Associativity
     {'A | B | C & D & E', '(A) (B) (C) (D) (E) &(3) |(3)'},
     -- More associativity
@@ -68,7 +68,7 @@ context("Rspamd expressions", function()
       if not c[2] then
         assert_nil(expr, "Should not be able to parse " .. c[1])
       else
-        assert_not_nil(expr, "Cannot parse " .. c[1])
+        assert_not_nil(expr, "Cannot parse " .. c[1] .. '; error: ' .. (err or 'wut??'))
         assert_equal(expr:to_string(), c[2], string.format("Evaluated expr to '%s', expected: '%s'",
             expr:to_string(), c[2]))
       end
@@ -99,7 +99,7 @@ context("Rspamd expressions", function()
       local expr,err = rspamd_expression.create(c[1],
           {parse_func, process_func}, pool)
 
-      assert_not_nil(expr, "Cannot parse " .. c[1])
+      assert_not_nil(expr, "Cannot parse " .. c[1] .. '; error: ' .. (err or 'wut??'))
       --print(expr)
       res = expr:process(atoms)
       assert_equal(res, c[2], string.format("Processed expr '%s'{%s} returned '%d', expected: '%d'",