aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/maillist.lua
diff options
context:
space:
mode:
authorJean-Louis Dupond <jean-louis@dupond.be>2017-07-14 14:24:04 +0200
committerJean-Louis Dupond <jean-louis@dupond.be>2017-07-14 14:38:44 +0200
commit92220a36f82edccc72b49e0fb3896b7e1be74098 (patch)
tree7324bfeb0e9ea1dfd7df62a6509241c99325dc7a /src/plugins/lua/maillist.lua
parent3be2002b3605f3792221122283cacb3f7c5c0cb9 (diff)
downloadrspamd-92220a36f82edccc72b49e0fb3896b7e1be74098.tar.gz
rspamd-92220a36f82edccc72b49e0fb3896b7e1be74098.zip
[Fix] Detection of maillist optimized and fixed
Some maillists were not detected correctly. Because by default all mails were checked for 'List-Unsubscribe' and 'List-Post' headers. But those headers do not exist on all maillists. For example majordomo detection was broken because of this.
Diffstat (limited to 'src/plugins/lua/maillist.lua')
-rw-r--r--src/plugins/lua/maillist.lua31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/plugins/lua/maillist.lua b/src/plugins/lua/maillist.lua
index 093e3164b..62ecc0341 100644
--- a/src/plugins/lua/maillist.lua
+++ b/src/plugins/lua/maillist.lua
@@ -28,6 +28,7 @@ local symbol = 'MAILLIST'
-- List-Help: <mailto:
-- List-Unsubscribe: <mailto:[a-zA-Z\.-]+-unsubscribe@
-- List-Subscribe: <mailto:[a-zA-Z\.-]+-subscribe@
+-- RFC 2919 headers exist
local function check_ml_ezmlm(task)
-- Mailing-List
local header = task:get_header('mailing-list')
@@ -66,10 +67,10 @@ end
-- List-Help: <mailto:
-- List-Post: <mailto:
-- List-Subscribe: .*<mailto:.*=subscribe>
--- List-Id:
-- List-Unsubscribe: .*<mailto:.*=unsubscribe>
-- List-Archive:
-- X-Mailman-Version: \d
+-- RFC 2919 headers exist
local function check_ml_mailman(task)
-- Mailing-List
local header = task:get_header('x-mailman-version')
@@ -78,7 +79,7 @@ local function check_ml_mailman(task)
end
-- Precedence
header = task:get_header('precedence')
- if not header or (not string.match(header, '^bulk$') and not string.match(header, '^list$')) then
+ if not header or (header ~= 'bulk' and header ~= 'list') then
return false
end
-- For reminders we have other headers than for normal messages
@@ -96,10 +97,6 @@ local function check_ml_mailman(task)
end
-- Other headers
- header = task:get_header('list-id')
- if not header then
- return false
- end
header = task:get_header('list-post')
if not header or not string.find(header, '^<mailto:') then
return false
@@ -169,20 +166,6 @@ local function check_ml_subscriberu(task)
end
--- RFC 2369 headers
-local function check_rfc2369(task)
- local header = task:get_header('List-Unsubscribe')
- if not header or not string.find(header, '<.+>') then
- return false
- end
- header = task:get_header('List-Post')
- if not header or not string.find(header, '<.+>') then
- return false
- end
-
- return true
-end
-
-- RFC 2919 headers
local function check_rfc2919(task)
local header = task:get_header('List-Id')
@@ -190,7 +173,7 @@ local function check_rfc2919(task)
return false
end
- return check_rfc2369(task)
+ return true
end
-- Google groups detector
@@ -214,11 +197,12 @@ end
-- Majordomo detector
-- Check Sender for owner- or -owner
-- Check Precedence for 'Bulk' or 'List'
+-- RFC 2919 headers exist
--
-- And nothing more can be extracted :(
local function check_ml_majordomo(task)
local header = task:get_header('Sender')
- if not header or (not string.find(header, '^owner-.*$') and not string.find(header, '^.*-owner$')) then
+ if not header or (not string.find(header, '^owner-.*$') and not string.find(header, '^.*-owner@.*$')) then
return false
end
@@ -246,13 +230,14 @@ end
local function check_ml_generic(task)
local header = task:get_header('Precedence')
- if not header or (header ~= 'list' and header ~= 'bulk') then
+ if not header then
return false
end
return check_rfc2919(task)
end
+-- RFC 2919 headers exist
local function check_maillist(task)
if check_ml_generic(task) then
if check_ml_ezmlm(task) then