]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Properly handle MIME headers in SA plugin
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Apr 2016 14:05:18 +0000 (15:05 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Apr 2016 14:05:18 +0000 (15:05 +0100)
src/lua/lua_config.c
src/plugins/lua/spamassassin.lua

index 6f994da534373dba93e93443ae644fe4b6724c1f..7d63928187dde948560737aaef558145d6def2d9 100644 (file)
@@ -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");
                        }
index 8ab37cf7e0a6988d575b8fe0d2e45367b004a204..a73b56d062b00f4b005441268098cf2c7b1225b5 100644 (file)
@@ -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