Browse Source

[Fix] Fix parsing of maps definitions

pull/4870/head
Vsevolod Stakhov 2 months ago
parent
commit
149e4cccf3
No account linked to committer's email address
1 changed files with 9 additions and 2 deletions
  1. 9
    2
      lualib/lua_maps.lua

+ 9
- 2
lualib/lua_maps.lua View File

end end


if opt[1] then if opt[1] then
local function check_plain_map(line)
return lua_util.str_startswith('http', line)
or lua_util.str_startswith('file:', line)
or lua_util.str_startswith('/', line)
end
-- Adjust each element if needed -- Adjust each element if needed
local adjusted local adjusted
for i, source in ipairs(opt) do for i, source in ipairs(opt) do
if mtype == 'radix' then if mtype == 'radix' then


if string.find(opt[1], '^%d') then if string.find(opt[1], '^%d') then
-- List of numeric stuff (hope it's ipnets definitions)
local map = rspamd_config:radix_from_ucl(opt) local map = rspamd_config:radix_from_ucl(opt)


if map then if map then
end end
end end
elseif mtype == 'regexp' or mtype == 'glob' then elseif mtype == 'regexp' or mtype == 'glob' then
if string.find(opt[1], '^/%a') or string.find(opt[1], '^http') then
if check_plain_map(opt[1]) then
-- Plain table -- Plain table
local map = rspamd_config:add_map { local map = rspamd_config:add_map {
type = mtype, type = mtype,
end end
end end
else else
if string.find(opt[1], '^/%a') or string.find(opt[1], '^http') then
-- Not regexp/glob
if check_plain_map(opt[1]) then
-- Plain table -- Plain table
local map = rspamd_config:add_map { local map = rspamd_config:add_map {
type = mtype, type = mtype,

Loading…
Cancel
Save