From 149e4cccf34eaa6edefe91565d0295d7f45faf82 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 10 Mar 2024 15:43:01 +0000 Subject: [Fix] Fix parsing of maps definitions --- lualib/lua_maps.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua index d3573100a..a67e11b63 100644 --- a/lualib/lua_maps.lua +++ b/lualib/lua_maps.lua @@ -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, -- cgit v1.2.3