From: Vsevolod Stakhov Date: Wed, 17 Feb 2016 23:42:46 +0000 (+0000) Subject: Fix negation for header rules in SA plugin X-Git-Tag: 1.2.0~210 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0ac0e550a387085659c4c6556021da601d93aa34;p=rspamd.git Fix negation for header rules in SA plugin --- diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua index 4f41681e6..988abf011 100644 --- a/src/plugins/lua/spamassassin.lua +++ b/src/plugins/lua/spamassassin.lua @@ -981,6 +981,7 @@ local function post_process() -- Header rules _.each(function(k, r) local f = function(task) + local raw = false local check = {} -- Cached path for ordinary expressions @@ -1006,9 +1007,14 @@ local function post_process() raw = h['raw'], }) - if h['not'] then - return not ret + if r['not'] then + if ret ~= 0 then + ret = 0 + else + ret = 1 + end end + return ret end @@ -1070,14 +1076,16 @@ local function post_process() return 0 end + local ret = 0 for i, c in ipairs(check) do local match = sa_regexp_match(c, r['re'], raw, r) if (match and not r['not']) or (not match and r['not']) then - return match + ret = 1 end + end - return 0 + return ret end if r['score'] then local real_score = r['score'] * calculate_score(k, r)