From: Vsevolod Stakhov Date: Tue, 31 Mar 2015 13:13:10 +0000 (+0100) Subject: Support [if-unset: blah] X-Git-Tag: 0.9.0~374 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d1537e6052a3d545e9b63934f76b6ec5e5475157;p=rspamd.git Support [if-unset: blah] --- diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua index 001798679..19b5737fd 100644 --- a/src/plugins/lua/spamassassin.lua +++ b/src/plugins/lua/spamassassin.lua @@ -180,6 +180,16 @@ local function process_sa_conf(f) end cur_rule['re_expr'] = words_to_re(words, 4) + local unset_comp = string.find(cur_rule['re_expr'], '%s+%[if%-unset:') + if unset_comp then + -- We have optional part that needs to be processed + unset = string.match(string.sub(cur_rule['re_expr'], unset_comp), + '%[if%-unset:%s*([^%]%s]+)]') + cur_rule['unset'] = unset + -- Cut it down + cur_rule['re_expr'] = string.sub(cur_rule['re_expr'], 1, unset_comp - 1) + end + cur_rule['re'] = rspamd_regexp.create_cached(cur_rule['re_expr']) if not cur_rule['re'] then @@ -317,7 +327,9 @@ _.each(function(k, r) end acc = acc .. str - end + end + elseif r['unset'] then + acc = acc .. r['unset'] end return acc