summaryrefslogtreecommitdiffstats
path: root/src/plugins/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-10-14 18:46:50 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-10-14 18:46:50 +0400
commit9ebf3a1a948f328543101ff1d2ab0f7521de8963 (patch)
treea944ec5e2951314c7fda39ba2628a7fff63ce165 /src/plugins/lua
parentd16336b4929ac76a1661b9c7dafd28568e6e0859 (diff)
downloadrspamd-9ebf3a1a948f328543101ff1d2ab0f7521de8963.tar.gz
rspamd-9ebf3a1a948f328543101ff1d2ab0f7521de8963.zip
* Fix getting of message headers from lua plugins
* Fix forged recipients plugin
Diffstat (limited to 'src/plugins/lua')
-rw-r--r--src/plugins/lua/forged_recipients.lua31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/plugins/lua/forged_recipients.lua b/src/plugins/lua/forged_recipients.lua
index b3aa2f577..d3463daae 100644
--- a/src/plugins/lua/forged_recipients.lua
+++ b/src/plugins/lua/forged_recipients.lua
@@ -9,26 +9,37 @@ function check_forged_headers(task)
local msg = task:get_message()
local smtp_rcpt = task:get_recipients()
local res = false
-
+
if smtp_rcpt then
local mime_rcpt = msg:get_header('To')
local mime_cc = msg:get_header('Cc')
+ local count = 0
+ if mime_rcpt then
+ count = table.maxn(mime_rcpt)
+ end
+ if mime_cc then
+ count = count + table.maxn(mime_cc)
+ end
-- Check recipients count
- if table.maxn(mime_rcpt) + table.maxn(mime_cc) <= table.maxn(smtp_rcpt) then
+ if count <= table.maxn(smtp_rcpt) then
task:insert_result(metric, symbol_rcpt, 1)
else
-- Find pair for each smtp recipient recipient in To or Cc headers
for _,sr in ipairs(smtp_rcpt) do
- for _,mr in ipairs(mime_rcpt) do
- if string.find(mr, sr) then
- res = true
- break
+ if mime_rcpt then
+ for _,mr in ipairs(mime_rcpt) do
+ if string.find(mr, sr) then
+ res = true
+ break
+ end
end
end
- for _,mr in ipairs(mime_cc) do
- if string.find(mr, sr) then
- res = true
- break
+ if mime_cc then
+ for _,mr in ipairs(mime_cc) do
+ if string.find(mr, sr) then
+ res = true
+ break
+ end
end
end