diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-07 11:14:59 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-07 11:14:59 +0000 |
commit | 407f3c9c0a151ff9c6322e207db6b7c78619b6ad (patch) | |
tree | 5303454ab18b4802026b42eef469e1cf8a5ea9df | |
parent | ec688d0aaea939259bf01cd338dd75f60ab12e10 (diff) | |
download | rspamd-407f3c9c0a151ff9c6322e207db6b7c78619b6ad.tar.gz rspamd-407f3c9c0a151ff9c6322e207db6b7c78619b6ad.zip |
Add support for Mail::SpamAssassin::Plugin::MIMEHeader
-rw-r--r-- | src/plugins/lua/spamassassin.lua | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua index 7055b7bfc..ea2f95477 100644 --- a/src/plugins/lua/spamassassin.lua +++ b/src/plugins/lua/spamassassin.lua @@ -44,7 +44,8 @@ local known_plugins = { 'Mail::SpamAssassin::Plugin::ReplaceTags', 'Mail::SpamAssassin::Plugin::RelayEval', 'Mail::SpamAssassin::Plugin::MIMEEval', - 'Mail::SpamAssassin::Plugin::BodyEval' + 'Mail::SpamAssassin::Plugin::BodyEval', + 'Mail::SpamAssassin::Plugin::MIMEHeader', } -- Internal variables @@ -534,7 +535,7 @@ local function process_sa_conf(f) return w ~= "" end, _.iter(split(l))))) - if words[1] == "header" then + if words[1] == "header" or words[1] == 'mimeheader' then -- header SYMBOL Header ~= /regexp/ if valid_rule then insert_cur_rule() @@ -567,6 +568,11 @@ local function process_sa_conf(f) handle_header_def(words[3], cur_rule) end + if words[1] == 'mimeheader' then + cur_rule['ordinary'] = false + cur_rule['mime'] = true + end + if cur_rule['re'] and cur_rule['symbol'] and (cur_rule['header'] or cur_rule['function']) then valid_rule = true @@ -961,7 +967,25 @@ _.each(function(k, r) local headers = {} local hname = h['header'] - local hdr = task:get_header_full(hname, h['strong']) + local hdr + if h['mime'] then + local parts = task:get_parts() + for i,p in ipairs(parts) do + local m_hdr = p:get_header_full(hname, h['strong']) + + if m_hdr then + if not hdr then + hdr = {} + end + for k,mh in ipairs(m_hdr) do + table.insert(hdr, mh) + end + end + end + else + hdr = task:get_header_full(hname, h['strong']) + end + if hdr then for n, rh in ipairs(hdr) do -- Subject for optimization |