From 2bec49d2580bcda5c7d143b609b88e5076a37a2d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 9 Apr 2016 13:18:53 +0100 Subject: [PATCH] [Feature] Support mime regexps in the expressions --- src/libmime/mime_expressions.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c index f5e6d4e48..ea8af2dcd 100644 --- a/src/libmime/mime_expressions.c +++ b/src/libmime/mime_expressions.c @@ -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); -- 2.39.5