diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-02-08 23:11:59 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-08 23:11:59 +0000 |
commit | 326e04c91f4852810f6b3eb02c34e1907e7ccb15 (patch) | |
tree | 162c5b0936a953c8a872e60915f402ac3adc39b8 | |
parent | 225a25c91fc00e6d2523a7352c266104cd2d220a (diff) | |
parent | 0b69b0452e370f33b678bf87fc041ae5e2f86cc8 (diff) | |
download | rspamd-326e04c91f4852810f6b3eb02c34e1907e7ccb15.tar.gz rspamd-326e04c91f4852810f6b3eb02c34e1907e7ccb15.zip |
Merge pull request #1406 from fatalbanana/mm
[Minor] Multimap Received headers: fixes
-rw-r--r-- | src/plugins/lua/multimap.lua | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index dd474d0c8..a5152a458 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -543,28 +543,34 @@ local function multimap_callback(task, rule) local max_pos = tonumber(r['max_pos']) if min_pos then if min_pos < 0 then - if (pos - (min_pos*-1)) < pos then - return - end - else - if pos < min_pos then - return + if min_pos == -1 then + if (pos ~= total) then + return + end + else + if pos <= (total - (min_pos*-1)) then + return + end end + elseif pos < min_pos then + return end end if max_pos then - if max_pos < 0 then - if (pos - (max_pos*-1)) > pos then + if max_pos < -1 then + if (total - (max_pos*-1)) >= pos then return end - else + elseif max_pos > 0 then if pos > max_pos then return end end end if filter == 'real_ip' or filter == 'from_ip' then - v = rspamd_ip.from_string(v) + if type(v) == 'string' then + v = rspamd_ip.from_string(v) + end if v and v:is_valid() then match_rule(r, v) end @@ -706,7 +712,12 @@ local function multimap_callback(task, rule) received = function() local hdrs = task:get_received_headers() if hdrs and hdrs[1] then - local num_hdrs = #hdrs + local num_hdrs = 0 + for i in ipairs(hdrs) do + if i > num_hdrs then + num_hdrs = i + end + end for pos, h in ipairs(hdrs) do match_received_header(rule, pos, num_hdrs, h) end |