From: Vsevolod Stakhov Date: Mon, 11 Apr 2016 14:05:18 +0000 (+0100) Subject: [Fix] Properly handle MIME headers in SA plugin X-Git-Tag: 1.2.3~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d8c5060dc65e3baf7b3b94dece4251a457449aa8;p=rspamd.git [Fix] Properly handle MIME headers in SA plugin --- diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 6f994da53..7d6392818 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -1617,8 +1617,10 @@ lua_config_register_regexp (lua_State *L) else { type = rspamd_re_cache_type_from_string (type_str); - if ((type == RSPAMD_RE_HEADER || type == RSPAMD_RE_RAWHEADER) - && header_str == NULL) { + if ((type == RSPAMD_RE_HEADER || + type == RSPAMD_RE_RAWHEADER || + type == RSPAMD_RE_MIMEHEADER) && + header_str == NULL) { msg_err_config ( "header argument is mandatory for header/rawheader regexps"); } diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua index 8ab37cf7e..a73b56d06 100644 --- a/src/plugins/lua/spamassassin.lua +++ b/src/plugins/lua/spamassassin.lua @@ -724,8 +724,9 @@ local function process_sa_conf(f) end if words[1] == 'mimeheader' then - cur_rule['ordinary'] = false cur_rule['mime'] = true + else + cur_rule['mime'] = false end if cur_rule['re'] and cur_rule['symbol'] and @@ -735,27 +736,46 @@ local function process_sa_conf(f) if cur_rule['header'] and cur_rule['ordinary'] then for i,h in ipairs(cur_rule['header']) do if type(h) == 'string' then - rspamd_config:register_regexp({ - re = cur_rule['re'], - type = 'header', - header = h, - pcre_only = is_pcre_only(cur_rule['symbol']), - }) - else - if h['raw'] then + if cur_rule['mime'] then rspamd_config:register_regexp({ re = cur_rule['re'], - type = 'rawheader', - header = h['header'], + type = 'mimeheader', + header = h, pcre_only = is_pcre_only(cur_rule['symbol']), }) else rspamd_config:register_regexp({ re = cur_rule['re'], type = 'header', + header = h, + pcre_only = is_pcre_only(cur_rule['symbol']), + }) + end + else + h['mime'] = cur_rule[mime] + if cur_rule['mime'] then + rspamd_config:register_regexp({ + re = cur_rule['re'], + type = 'mimeheader', header = h['header'], pcre_only = is_pcre_only(cur_rule['symbol']), }) + else + if h['raw'] then + rspamd_config:register_regexp({ + re = cur_rule['re'], + type = 'rawheader', + header = h['header'], + pcre_only = is_pcre_only(cur_rule['symbol']), + }) + else + rspamd_config:register_regexp({ + re = cur_rule['re'], + type = 'header', + header = h['header'], + pcre_only = is_pcre_only(cur_rule['symbol']), + }) + end end end end