]> source.dussan.org Git - rspamd.git/commitdiff
fix compatibility with lua-5.4 3852/head
authorTomohiro "Tomo-p" KATO <tomop@teamgedoh.net>
Mon, 15 Feb 2021 15:29:59 +0000 (00:29 +0900)
committerTomohiro "Tomo-p" KATO <tomop@teamgedoh.net>
Thu, 19 Aug 2021 17:24:31 +0000 (02:24 +0900)
src/libserver/cfg_rcl.c
src/libstat/stat_config.c
src/lua/lua_thread_pool.cxx
src/plugins/fuzzy_check.c
src/plugins/lua/hfilter.lua
src/plugins/lua/milter_headers.lua

index b19a1dedc28057acb1b535cd1c9e20d4a25d6b4e..d91ebf3aee6186e9eb434850cced6cc41f909a28 100644 (file)
@@ -3571,6 +3571,9 @@ rspamd_rcl_maybe_apply_lua_transform (struct rspamd_config *cfg)
                return;
        }
        else {
+#if LUA_VERSION_NUM >= 504
+               lua_settop(L, -2);
+#endif
                if (lua_type (L, -1) != LUA_TFUNCTION) {
                        msg_warn_config ("lua script must return "
                                        "function and not %s",
index 17d0fdcc70d204beaf915209280c37e759eb588b..0c9ae2ed085f17e9c454a7f6b32c5c6181f15d14 100644 (file)
@@ -172,6 +172,9 @@ rspamd_stat_init (struct rspamd_config *cfg, struct ev_loop *ev_base)
                                lua_tostring (L, -1));
        }
        else {
+#if LUA_VERSION_NUM >= 504
+               lua_settop(L, -2);
+#endif
                if (lua_type (L, -1) != LUA_TTABLE) {
                        msg_err_config ("lua stat must return "
                                                        "table and not %s",
index 62da49482e9379649a216ca84c14fbb410bdec0f..dc6c15163a6d5cefd1059018f18828502c936cc1 100644 (file)
@@ -261,12 +261,15 @@ lua_thread_pool_restore_callback_full(struct lua_callback_state *cbs,
 
 static gint
 lua_do_resume_full(lua_State *L, gint narg, const gchar *loc) {
+#if LUA_VERSION_NUM >= 504
+       int nres;
+#endif
        msg_debug_lua_threads ("%s: lua_do_resume_full", loc);
 #if LUA_VERSION_NUM < 502
        return lua_resume(L, narg);
 #else
 #if LUA_VERSION_NUM >= 504
-       return lua_resume (L, NULL, narg, NULL);
+       return lua_resume (L, NULL, narg, &nres);
 #else
        return lua_resume (L, NULL, narg);
 #endif
index 722daeacbd5a0d4b0b49abaab2b3537b3590c650..ea8bcf7567e4c317c42b2e7b3b94f6c3050e0af9 100644 (file)
@@ -1006,6 +1006,9 @@ fuzzy_check_module_config (struct rspamd_config *cfg, bool validate)
                fuzzy_module_ctx->enabled = FALSE;
        }
        else {
+#if LUA_VERSION_NUM >= 504
+               lua_settop(L, -2);
+#endif
                if (lua_type (L, -1) != LUA_TTABLE) {
                        msg_err_config ("lua fuzzy must return "
                                                        "table and not %s",
index 9179f63b80425896f08c5a9811bbe5b8d8d9c0e4..3889eaa5bb6b398ab82496a5235772ec89728918 100644 (file)
@@ -357,7 +357,7 @@ local function hfilter_callback(task)
               local lines =  html_text_part:get_lines_count()
               if lines > 0 and lines < 2 then
                 task:insert_result('HFILTER_URL_ONELINE', 1.00,
-                  string.format('html:%d:%d', sc, lines))
+                  string.format('html:%d:%d', math.floor(sc), lines))
               end
             end
           end
@@ -376,7 +376,7 @@ local function hfilter_callback(task)
             local lines = plain_text_part:get_lines_count()
             if lines > 0 and lines < 2 then
               task:insert_result('HFILTER_URL_ONELINE', 1.00,
-                string.format('plain:%d:%d', rel, lines))
+                string.format('plain:%d:%d', math.floor(rel), lines))
             end
           end
         end
index 0dfaa9e030d946bf710e9d491f1a8dda916bb55b..1b58cee860610b150ec13d3bd4ebc07accb6b5c7 100644 (file)
@@ -383,7 +383,7 @@ local function milter_headers(task)
     if local_mod.remove then
       remove[local_mod.header] = local_mod.remove
     end
-    add[local_mod.header] = string.rep(local_mod.char, score)
+    add[local_mod.header] = string.rep(local_mod.char, math.floor(score))
   end
 
   local function spam_header (class, name, value, remove_v)