From 86ae36d19ff7291784e1a638fe192a66a160d538 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 28 Mar 2015 22:36:28 +0000 Subject: [PATCH] Add some preliminary priorities for mime expressions. --- src/libmime/mime_expressions.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c index 2e8fdeedc..afae67487 100644 --- a/src/libmime/mime_expressions.c +++ b/src/libmime/mime_expressions.c @@ -932,8 +932,37 @@ rspamd_mime_expr_process_regexp (struct rspamd_regexp_atom *re, static gint rspamd_mime_expr_priority (rspamd_expression_atom_t *atom) { - /* TODO: implement priorities for mime expressions */ - return 0; + struct rspamd_mime_atom *mime_atom = atom->data; + gint ret = 0; + + switch (mime_atom->type) { + case MIME_ATOM_INTERNAL_FUNCTION: + /* Prioritize internal functions slightly */ + ret = 50; + break; + case MIME_ATOM_LUA_FUNCTION: + ret = 50; + break; + case MIME_ATOM_REGEXP: + switch (mime_atom->d.re->type) { + case REGEXP_HEADER: + case REGEXP_RAW_HEADER: + ret = 100; + break; + case REGEXP_URL: + ret = 90; + break; + case REGEXP_MIME: + ret = 10; + break; + default: + /* For message regexp */ + ret = 0; + break; + } + } + + return ret; } static void -- 2.39.5