]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Support mime regexps in the expressions
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 9 Apr 2016 12:18:53 +0000 (13:18 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 9 Apr 2016 12:18:53 +0000 (13:18 +0100)
src/libmime/mime_expressions.c

index f5e6d4e48e3fddbd0a26dd074009c88e2da40077..ea8af2dcd59be16de6c9bbdac9f8aee1b6ae6003 100644 (file)
@@ -282,6 +282,14 @@ rspamd_mime_expr_parse_regexp_atom (rspamd_mempool_t * pool, const gchar *line,
                        result->type = RSPAMD_RE_HEADER;
                        p++;
                        break;
+               case 'R':
+                       result->type = RSPAMD_RE_RAWHEADER;
+                       p++;
+                       break;
+               case 'B':
+                       result->type = RSPAMD_RE_MIMEHEADER;
+                       p++;
+                       break;
                case 'M':
                        result->type = RSPAMD_RE_BODY;
                        p++;
@@ -302,6 +310,7 @@ rspamd_mime_expr_parse_regexp_atom (rspamd_mempool_t * pool, const gchar *line,
                        result->type = RSPAMD_RE_RAWHEADER;
                        p++;
                        break;
+               /* Other flags */
                case 'T':
                        result->is_test = TRUE;
                        p++;
@@ -326,6 +335,15 @@ rspamd_mime_expr_parse_regexp_atom (rspamd_mempool_t * pool, const gchar *line,
                return NULL;
        }
 
+       if ((result->type == RSPAMD_RE_HEADER ||
+                       result->type == RSPAMD_RE_RAWHEADER ||
+                       result->type == RSPAMD_RE_MIMEHEADER) &&
+                       result->header == NULL) {
+               msg_err_pool ("header regexp: '%s' has no header part", src);
+               return NULL;
+       }
+
+
        result->regexp_text = rspamd_mempool_strdup (pool, start);
        dbegin = result->regexp_text + (begin - start);
        dend = result->regexp_text + (end - start);