aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-06-17 11:05:40 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-06-17 11:05:40 +0100
commit8aae3eae774dae1e56e6b401b42aa20bd777112d (patch)
tree29acaf8eaf6d8acb3fdc290a8df2dcb096985fd5
parent8139bbca9cf81108c17b607acad8971e9a7d404b (diff)
downloadrspamd-8aae3eae774dae1e56e6b401b42aa20bd777112d.tar.gz
rspamd-8aae3eae774dae1e56e6b401b42aa20bd777112d.zip
[Minor] Fix some more issues
-rw-r--r--src/lua/lua_expression.c5
-rw-r--r--test/lua/unit/expressions.lua10
2 files changed, 7 insertions, 8 deletions
diff --git a/src/lua/lua_expression.c b/src/lua/lua_expression.c
index b2addd30c..8c44eba08 100644
--- a/src/lua/lua_expression.c
+++ b/src/lua/lua_expression.c
@@ -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");
diff --git a/test/lua/unit/expressions.lua b/test/lua/unit/expressions.lua
index 8633560ba..ce6c92dca 100644
--- a/test/lua/unit/expressions.lua
+++ b/test/lua/unit/expressions.lua
@@ -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'",