aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-18 18:36:29 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-18 18:36:29 +0100
commite8a54f7987f0b753e6a4d6bacc76d9766b2a8303 (patch)
treeed0af89be94bc51c7a785d5091b12d2b6f3de672
parent31138dd8acc790c0129fb488584311c85c96f87c (diff)
downloadrspamd-e8a54f7987f0b753e6a4d6bacc76d9766b2a8303.tar.gz
rspamd-e8a54f7987f0b753e6a4d6bacc76d9766b2a8303.zip
[Fix] Meta: Filter some more values
-rw-r--r--lualib/lua_meta.lua17
1 files changed, 13 insertions, 4 deletions
diff --git a/lualib/lua_meta.lua b/lualib/lua_meta.lua
index 3ed416158..b7c9286d7 100644
--- a/lualib/lua_meta.lua
+++ b/lualib/lua_meta.lua
@@ -18,6 +18,7 @@ local exports = {}
local N = "metatokens"
local ts = require("tableshape").types
+local logger = require "rspamd_logger"
-- Metafunctions
local function meta_size_function(task)
@@ -454,6 +455,11 @@ local function rspamd_gen_metatokens(task, names)
for i,tok in ipairs(ct) do
lua_util.debugm(N, task, "metatoken: %s = %s",
mt.names[i], tok)
+ if tok ~= tok or tok == math.huge() then
+ logger.errx(task, 'metatoken %s returned %s; replace it with 0 for sanity',
+ mt.names[i], tok)
+ tok = 0.0
+ end
table.insert(metatokens, tok)
end
end
@@ -462,10 +468,15 @@ local function rspamd_gen_metatokens(task, names)
end
else
- local logger = require "rspamd_logger"
for _,n in ipairs(names) do
if metatokens_by_name[n] then
- table.insert(metatokens, metatokens_by_name[n](task))
+ local tok = metatokens_by_name[n](task)
+ if tok ~= tok or tok == math.huge() then
+ logger.errx(task, 'metatoken %s returned %s; replace it with 0 for sanity',
+ n, tok)
+ tok = 0.0
+ end
+ table.insert(metatokens, tok)
else
logger.errx(task, 'unknown metatoken: %s', n)
end
@@ -485,7 +496,6 @@ local function rspamd_gen_metatokens_table(task)
local ct = mt.cb(task)
for i,tok in ipairs(ct) do
if tok ~= tok or tok == math.huge() then
- local logger = require "rspamd_logger"
logger.errx(task, 'metatoken %s returned %s; replace it with 0 for sanity',
mt.names[i], tok)
tok = 0.0
@@ -519,7 +529,6 @@ exports.add_metafunction = function(tbl)
local ret, err = meta_schema(tbl)
if not ret then
- local logger = require "rspamd_logger"
logger.errx('cannot add metafunction: %s', err)
else
table.insert(metafunctions, tbl)