aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-02-16 17:00:13 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-02-16 17:00:13 +0300
commitbbc68360a114fb5849c62d6bc41264c9906d7aca (patch)
tree37391f1210c38c3d72e49a4d9af0ebba1c9a9571
parenta1d1360ccbde0637045a1adc2098065550f0496b (diff)
downloadrspamd-bbc68360a114fb5849c62d6bc41264c9906d7aca.tar.gz
rspamd-bbc68360a114fb5849c62d6bc41264c9906d7aca.zip
* Improve forged_recipients plugin [1]
Add loading of local rules to rspamd.lua [1] [1] Suggested by Victor Ustugov
-rw-r--r--conf/lua/rspamd.lua14
-rw-r--r--src/plugins/lua/forged_recipients.lua28
2 files changed, 39 insertions, 3 deletions
diff --git a/conf/lua/rspamd.lua b/conf/lua/rspamd.lua
index 2f337aa9f..e85a971d3 100644
--- a/conf/lua/rspamd.lua
+++ b/conf/lua/rspamd.lua
@@ -40,3 +40,17 @@ reconf['R_EMPTY_IMAGE'] = function (task)
return false
end
+
+local function file_exists(filename)
+ local file = io.open(filename)
+ if file then
+ io.close(file)
+ return true
+ else
+ return false
+ end
+end
+
+if file_exists('rspamd.local.lua') then
+ dofile('rspamd.local.lua')
+end
diff --git a/src/plugins/lua/forged_recipients.lua b/src/plugins/lua/forged_recipients.lua
index 6b6ec298b..d082b386d 100644
--- a/src/plugins/lua/forged_recipients.lua
+++ b/src/plugins/lua/forged_recipients.lua
@@ -31,7 +31,15 @@ function check_forged_headers(task)
end
if mime_rcpt then
for _,mr in ipairs(mime_rcpt) do
- if string.find(mr, sr) then
+ 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
@@ -39,7 +47,14 @@ function check_forged_headers(task)
end
if mime_cc then
for _,mr in ipairs(mime_cc) do
- if string.find(mr, sr) then
+ 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
@@ -57,7 +72,14 @@ function check_forged_headers(task)
local smtp_from = task:get_from()
if smtp_form then
local mime_from = msg:get_header('From')
- if not mime_from or not string.find(mime_from[0], smtp_from) then
+ 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
task:insert_result(symbol_sender, 1)
end
end