summaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/emails.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-11-20 00:12:14 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-11-20 00:12:14 +0000
commit890e8c17a266ebf27c6d5a10c3c9310f149f0172 (patch)
treeff563833f6b527219c1561b59eebd14645e6bd2e /src/plugins/lua/emails.lua
parentd71d16de876580dd29ce2bf3dffae2cd9f92a752 (diff)
downloadrspamd-890e8c17a266ebf27c6d5a10c3c9310f149f0172.tar.gz
rspamd-890e8c17a266ebf27c6d5a10c3c9310f149f0172.zip
Fix emailbl plugin.
Diffstat (limited to 'src/plugins/lua/emails.lua')
-rw-r--r--src/plugins/lua/emails.lua37
1 files changed, 10 insertions, 27 deletions
diff --git a/src/plugins/lua/emails.lua b/src/plugins/lua/emails.lua
index d99b0966b..0e7705c5f 100644
--- a/src/plugins/lua/emails.lua
+++ b/src/plugins/lua/emails.lua
@@ -82,20 +82,15 @@ function check_emails(task)
end
-- Add rule to ruleset
-local function add_emails_rule(params)
+local function add_emails_rule(key, obj)
local newrule = {
name = nil,
dnsbl = nil,
map = nil,
domain_only = false,
- symbol = nil
+ symbol = k
}
- for _,param in ipairs(params) do
- local _,_,name,value = string.find(param, '([a-zA-Z_0-9]+)%s*=%s*(.+)')
- if not name or not value then
- rspamd_logger.err('invalid rule: '..param)
- return nil
- end
+ for name,value in pairs(obj) do
if name == 'dnsbl' then
newrule['dnsbl'] = value
newrule['name'] = value
@@ -134,28 +129,16 @@ end
local opts = rspamd_config:get_all_opt('emails')
if opts then
- local strrules = opts['rule']
- if strrules then
- if type(strrules) == 'table' then
- for _,value in ipairs(strrules) do
- local params = split(value, ',')
- local rule = add_emails_rule (params)
- if not rule then
- rspamd_logger.err('cannot add rule: "'..value..'"')
- else
- if type(rspamd_config.get_api_version) ~= 'nil' then
- rspamd_config:register_virtual_symbol(rule['symbol'], 1.0)
- end
- end
- end
- elseif type(strrules) == 'string' then
- local params = split(strrules, ',')
- local rule = add_emails_rule (params)
+ for k,m in pairs(opts) do
+ if type(m) ~= 'table' then
+ rspamd_logger.err('parameter ' .. k .. ' is invalid, must be an object')
+ else
+ local rule = add_emails_rule(k, m)
if not rule then
- rspamd_logger.err('cannot add rule: "'..strrules..'"')
+ rspamd_logger.err('cannot add rule: "'..k..'"')
else
if type(rspamd_config.get_api_version) ~= 'nil' then
- rspamd_config:register_virtual_symbol(rule['symbol'], 1.0)
+ rspamd_config:register_virtual_symbol(m['symbol'], 1.0)
end
end
end