summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-11-24 13:42:23 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-11-24 13:42:23 +0000
commit664eeeca185f4f4c15f0124ade8bc9d6c3c6d537 (patch)
treec94e57ecef46dde83cb4ba7ecf440d1bb77611a6 /src
parent18b681e68af2bf46d1b153d910ae65109f148158 (diff)
downloadrspamd-664eeeca185f4f4c15f0124ade8bc9d6c3c6d537.tar.gz
rspamd-664eeeca185f4f4c15f0124ade8bc9d6c3c6d537.zip
[Fix] Fix set and regexp like static maps
Diffstat (limited to 'src')
-rw-r--r--src/lua/global_functions.lua32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/lua/global_functions.lua b/src/lua/global_functions.lua
index 8c0514d94..e89a5da64 100644
--- a/src/lua/global_functions.lua
+++ b/src/lua/global_functions.lua
@@ -451,29 +451,37 @@ function rspamd_map_add(mname, optname, mtype, description)
end
end
- ret.__data = data
- ret.get_key = function(t, k)
- for _,re in ipairs(t.__data) do
- if re:match(k) then return true end
- end
+ if #data > 0 then
+ ret.__data = data
+ ret.get_key = function(t, k)
+ for _,re in ipairs(t.__data) do
+ if re:match(k) then return true end
+ end
- return nil
+ return nil
+ end
+ return ret
end
else
local data = {}
+ local nelts = 0
for _,elt in ipairs(opt) do
if type(elt) == 'string' then
data[elt] = true
+ nelts = nelts + 1
end
end
- ret.__data = data
- ret.get_key = function(t, k)
- if k ~= '__data' then
- return t.__data[k]
- end
+ if nelts > 0 then
+ ret.__data = data
+ ret.get_key = function(t, k)
+ if k ~= '__data' then
+ return t.__data[k]
+ end
- return nil
+ return nil
+ end
+ return ret
end
end
else