From: Vsevolod Stakhov Date: Sun, 6 Jan 2019 17:00:24 +0000 (+0000) Subject: [Minor] Core: Add concept of mime only rules X-Git-Tag: 1.9.0~351 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f358aec84f8bc2aa38c17a79d79b7a0b26faa4a0;p=thirdparty%2Frspamd.git [Minor] Core: Add concept of mime only rules --- diff --git a/src/libserver/rspamd_symcache.c b/src/libserver/rspamd_symcache.c index 62340af3b0..f6487f4d8e 100644 --- a/src/libserver/rspamd_symcache.c +++ b/src/libserver/rspamd_symcache.c @@ -1382,7 +1382,8 @@ rspamd_symcache_check_symbol (struct rspamd_task *task, SET_START_BIT (checkpoint, dyn_item); if (!item->enabled || - (RSPAMD_TASK_IS_EMPTY (task) && !(item->type & SYMBOL_TYPE_EMPTY))) { + (RSPAMD_TASK_IS_EMPTY (task) && !(item->type & SYMBOL_TYPE_EMPTY)) || + (item->type & SYMBOL_TYPE_MIME_ONLY && !RSPAMD_TASK_IS_MIME(task))) { check = FALSE; } else if (item->specific.normal.condition_cb != -1) { diff --git a/src/libserver/rspamd_symcache.h b/src/libserver/rspamd_symcache.h index df495fc8ed..ab9c568e1d 100644 --- a/src/libserver/rspamd_symcache.h +++ b/src/libserver/rspamd_symcache.h @@ -47,6 +47,7 @@ enum rspamd_symbol_type { SYMBOL_TYPE_IDEMPOTENT = (1 << 12), /* Symbol cannot change metric */ SYMBOL_TYPE_SQUEEZED = (1 << 13), /* Symbol is squeezed inside Lua */ SYMBOL_TYPE_TRIVIAL = (1 << 14), /* Symbol is trivial */ + SYMBOL_TYPE_MIME_ONLY = (1 << 15), /* Symbol is mime only */ }; /** diff --git a/src/libserver/task.h b/src/libserver/task.h index 34e160dc02..7cdc095380 100644 --- a/src/libserver/task.h +++ b/src/libserver/task.h @@ -125,6 +125,7 @@ enum rspamd_task_stage { #define RSPAMD_TASK_IS_CLASSIFIED(task) (((task)->processed_stages & RSPAMD_TASK_STAGE_CLASSIFIERS)) #define RSPAMD_TASK_IS_EMPTY(task) (((task)->flags & RSPAMD_TASK_FLAG_EMPTY)) #define RSPAMD_TASK_IS_PROFILING(task) (((task)->flags & RSPAMD_TASK_FLAG_PROFILE)) +#define RSPAMD_TASK_IS_MIME(task) (((task)->flags & RSPAMD_TASK_FLAG_MIME)) struct rspamd_email_address; struct rspamd_lang_detector; diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 1965b49039..cc0ba7aedf 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -1501,6 +1501,9 @@ lua_parse_symbol_flags (const gchar *str) if (strstr (str, "trivial") != NULL) { ret |= SYMBOL_TYPE_TRIVIAL; } + if (strstr (str, "mime") != NULL) { + ret |= SYMBOL_TYPE_MIME_ONLY; + } } return ret;