diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-28 22:36:28 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-28 22:36:28 +0000 |
commit | 86ae36d19ff7291784e1a638fe192a66a160d538 (patch) | |
tree | 1d344336d967b1af6834f11f5dbe03a3e9efa9db /src/libmime/mime_expressions.c | |
parent | 8beb6fe20a322fe72faaabf8507503f138dbeb73 (diff) | |
download | rspamd-86ae36d19ff7291784e1a638fe192a66a160d538.tar.gz rspamd-86ae36d19ff7291784e1a638fe192a66a160d538.zip |
Add some preliminary priorities for mime expressions.
Diffstat (limited to 'src/libmime/mime_expressions.c')
-rw-r--r-- | src/libmime/mime_expressions.c | 33 |
1 files 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 |