aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-03 00:25:12 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-03 00:25:12 +0000
commit06cb63a5c6770c1814a4b137dc75ead78ddab864 (patch)
tree8607fd7b27f91a7b0f2de78642b01a6e88ace30c /src
parent8dd71d47800da5e8794b96bff8b9f796c337e7b3 (diff)
downloadrspamd-06cb63a5c6770c1814a4b137dc75ead78ddab864.tar.gz
rspamd-06cb63a5c6770c1814a4b137dc75ead78ddab864.zip
Closure fixes.
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lua/spamassassin.lua21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua
index a3f0c3ec5..cb5bbb842 100644
--- a/src/plugins/lua/spamassassin.lua
+++ b/src/plugins/lua/spamassassin.lua
@@ -83,6 +83,14 @@ local function process_sa_conf(f)
cur_rule['not'] = true
end
+ cur_rule['re_expr'] = words_to_re(words, 4)
+ cur_rule['re'] = rspamd_regexp.create_cached(cur_rule['re_expr'])
+
+ if not cur_rule['re'] then
+ rspamd_logger.warn(string.format("Cannot parse regexp '%s' for %s",
+ cur_rule['re_expr'], cur_rule['symbol']))
+ end
+
--Now check for modifiers inside header's name
local semicolon = string.find(cur_rule['header'], ':')
if semicolon then
@@ -94,12 +102,17 @@ local function process_sa_conf(f)
-- We can handle all only with 'raw' condition
if func == 'raw' then
cur_rule['type'] = 'function'
+ -- Pack closure
+ local re = cur_rule['re']
+ local not_f = cur_rule['not']
+ local sym = cur_rule['symbol']
cur_rule['function'] = function(task)
local hdr = task:get_raw_headers()
if hdr then
- local match = r['re']:match(rh['decoded'])
- if (match and not r['not']) or (not match and r['not']) then
- task:insert_result(k, 1.0)
+ local match = re:match(hdr)
+ if (match and not not_f) or
+ (not match and not_f) then
+ task:insert_result(sym, 1.0)
end
end
end
@@ -134,8 +147,6 @@ local function process_sa_conf(f)
rspamd_logger.info('MESSAGEID support is limited in ' .. cur_rule['symbol'])
end
- cur_rule['re_expr'] = words_to_re(words, 4)
- cur_rule['re'] = rspamd_regexp.create_cached(cur_rule['re_expr'])
if cur_rule['re'] and (cur_rule['header'] or cur_rule['function']) then
valid_rule = true
end