]> source.dussan.org Git - rspamd.git/commitdiff
Support [if-unset: blah]
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 31 Mar 2015 13:13:10 +0000 (14:13 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 31 Mar 2015 13:13:10 +0000 (14:13 +0100)
src/plugins/lua/spamassassin.lua

index 0017986792f10d19402bd1178a8f8a0c25d789fb..19b5737fdc2e9597aed41ed5b5ce76e9c431f4f9 100644 (file)
@@ -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