diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-01-07 15:41:34 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-01-07 15:41:34 +0000 |
commit | c143670bcacd9039a3d782de3a6b5beda53cc760 (patch) | |
tree | dca15f1f8d5a519d22dee937054fcee51f558523 | |
parent | d9f3f32336c7b8b063359c6d54a99e07dbead766 (diff) | |
download | rspamd-c143670bcacd9039a3d782de3a6b5beda53cc760.tar.gz rspamd-c143670bcacd9039a3d782de3a6b5beda53cc760.zip |
[Minor] Regexp: Allow to add mime only regexp rules
-rw-r--r-- | src/plugins/regexp.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index 897bbd277..01c086169 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -245,12 +245,34 @@ regexp_module_config (struct rspamd_config *cfg) } if (cur_item && (is_lua || valid_expression)) { + + flags = SYMBOL_TYPE_NORMAL; + elt = ucl_object_lookup (value, "mime_only"); + + if (elt) { + if (ucl_object_type (elt) != UCL_BOOLEAN) { + msg_err_config ( + "mime_only attribute is not boolean for symbol: '%s'", + cur_item->symbol); + + res = FALSE; + } + else { + if (ucl_object_toboolean (elt)) { + flags |= SYMBOL_TYPE_MIME_ONLY; + } + } + } + id = rspamd_symcache_add_symbol (cfg->cache, cur_item->symbol, 0, process_regexp_item, cur_item, - SYMBOL_TYPE_NORMAL, -1); + flags, -1); + + /* Reset flags */ + flags = 0; elt = ucl_object_lookup (value, "condition"); @@ -296,7 +318,7 @@ regexp_module_config (struct rspamd_config *cfg) if (elt) { if (ucl_object_type (elt) != UCL_BOOLEAN) { msg_err_config ( - "one_shot attribute is not numeric for symbol: '%s'", + "one_shot attribute is not boolean for symbol: '%s'", cur_item->symbol); res = FALSE; @@ -311,7 +333,7 @@ regexp_module_config (struct rspamd_config *cfg) if ((elt = ucl_object_lookup (value, "any_shot")) != NULL) { if (ucl_object_type (elt) != UCL_BOOLEAN) { msg_err_config ( - "any_shot attribute is not numeric for symbol: '%s'", + "any_shot attribute is not boolean for symbol: '%s'", cur_item->symbol); res = FALSE; @@ -341,7 +363,7 @@ regexp_module_config (struct rspamd_config *cfg) if (elt) { if (ucl_object_type (elt) != UCL_BOOLEAN) { msg_err_config ( - "one_param attribute is not numeric for symbol: '%s'", + "one_param attribute is not boolean for symbol: '%s'", cur_item->symbol); res = FALSE; |