local N = "metatokens"
local ts = require("tableshape").types
+local logger = require "rspamd_logger"
-- Metafunctions
local function meta_size_function(task)
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
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
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
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)