if type(settings.use_domain_custom) == 'string' then
-- Load custom function
local loadstring = loadstring or load
- local ret, res_or_err = pcall(loadstring(settings.use_domain_custom))
+ local chunk, err = loadstring(settings.use_domain_custom)
+ local ret, res_or_err
+ if chunk then
+ ret, res_or_err = pcall(chunk)
+ else
+ ret = false
+ res_or_err = err
+ end
+
if ret then
if type(res_or_err) == 'function' then
settings.use_domain_custom = res_or_err
inp = 'return function(...)\n' .. s .. '; end'
end
- local ret, res_or_err = pcall(loadstring(inp))
+ local chunk, err = loadstring(inp)
+ if not chunk then
+ return false, err
+ end
+
+ local ret, res_or_err = pcall(chunk)
if not ret or type(res_or_err) ~= 'function' then
return false, res_or_err
if rule.schema and rule.first_row and rule.get_row then
local first_row, get_row
local loadstring = loadstring or load
- local ret, res_or_err = pcall(loadstring(rule.first_row))
+ local ret, res_or_err
+ local chunk, err = loadstring(rule.first_row)
+ if chunk then
+ ret, res_or_err = pcall(chunk)
+ else
+ ret = false
+ res_or_err = err
+ end
if not ret or type(res_or_err) ~= 'function' then
rspamd_logger.errx(rspamd_config, 'invalid first_row (%s) - must be a function',
first_row = res_or_err
end
- ret, res_or_err = pcall(loadstring(rule.get_row))
+ chunk, err = loadstring(rule.get_row)
+ if chunk then
+ ret, res_or_err = pcall(chunk)
+ else
+ ret = false
+ res_or_err = err
+ end
if not ret or type(res_or_err) ~= 'function' then
rspamd_logger.errx(rspamd_config,