diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-03-04 19:38:04 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-03-04 19:38:04 +0300 |
commit | de9ac8f1938e09f3c6c3d6f261db4749b3b9ff01 (patch) | |
tree | ea861fa0702a4dd3103de7c24ebd164b4aa21855 /src/plugins/lua/forged_recipients.lua | |
parent | 2a2bc886c1b43a9c43a812959d7193cc03d7bc8d (diff) | |
download | rspamd-de9ac8f1938e09f3c6c3d6f261db4749b3b9ff01.tar.gz rspamd-de9ac8f1938e09f3c6c3d6f261db4749b3b9ff01.zip |
* Add multimaps for "FROM" and "TO" headers (mime an smtp data can be checked)
* Improve lua api for getting message's sender and recipients
Diffstat (limited to 'src/plugins/lua/forged_recipients.lua')
-rw-r--r-- | src/plugins/lua/forged_recipients.lua | 53 |
1 files changed, 5 insertions, 48 deletions
diff --git a/src/plugins/lua/forged_recipients.lua b/src/plugins/lua/forged_recipients.lua index d082b386d..366591377 100644 --- a/src/plugins/lua/forged_recipients.lua +++ b/src/plugins/lua/forged_recipients.lua @@ -10,57 +10,21 @@ function check_forged_headers(task) 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 + local mime_rcpt = task:get_recipients_headers() + local count = table.maxn(mime_rcpt) if count < table.maxn(smtp_rcpt) then task:insert_result(symbol_rcpt, 1) else -- Find pair for each smtp recipient recipient in To or Cc headers for _,sr in ipairs(smtp_rcpt) do - if sr:sub(1,1) == '<' then - -- Trim brackets - sr = string.sub(sr, 2, -2) - end if mime_rcpt then for _,mr in ipairs(mime_rcpt) do - local i = string.find(mr, '<', 1, true) - if i then - local j = string.find(mr, '>', i, true) - if j then - mr = string.sub(mr, i+1, j-1) - end - end - - if string.lower(mr) == string.lower(sr) then + if string.lower(mr['addr']) == string.lower(sr['addr']) then res = true break end end end - if mime_cc then - for _,mr in ipairs(mime_cc) do - local i = string.find(mr, '<', 1, true) - if i then - local j = string.find(mr, '>', i, true) - if j then - mr = string.sub(mr, i+1, j-1) - end - end - if string.lower(mr) == string.lower(sr) then - res = true - break - end - end - end - if not res then task:insert_result(symbol_rcpt, 1) break @@ -71,15 +35,8 @@ function check_forged_headers(task) -- Check sender local smtp_from = task:get_from() if smtp_form then - local mime_from = msg:get_header('From') - local i = string.find(mime_from[0], '<', 1, true) - if i then - local j = string.find(mime_from[0], '>', i, true) - if j then - mime_from[0] = string.sub(mime_from[0], i+1, j-1) - end - end - if not mime_from or not (string.lower(mime_from[0]) == string.lower(smtp_from)) then + local mime_from = task:get_from_headers() + if not mime_from or not (string.lower(mime_from[1]['addr']) == string.lower(smtp_from[1]['addr'])) then task:insert_result(symbol_sender, 1) end end |