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

@@ -294,6 +294,11 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback)
end

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
local adjusted
for i, source in ipairs(opt) do
@@ -311,6 +316,7 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback)
if mtype == 'radix' 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)

if map then
@@ -338,7 +344,7 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback)
end
end
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
local map = rspamd_config:add_map {
type = mtype,
@@ -372,7 +378,8 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback)
end
end
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
local map = rspamd_config:add_map {
type = mtype,

Loading…
Cancel
Save