diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-08-26 10:23:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-26 10:23:10 +0100 |
commit | 4b22c83c6522476a160cb9ee07d5f21006c2e70b (patch) | |
tree | 9d3d2ea2f1aa70b285cfaebde9cbf031e5e7219b | |
parent | 2e6f1ebd706f3e9023babcc19b69f838b5eff2a8 (diff) | |
parent | 2b70ad6a7617845b7c2d0c9d14c4ff35528cb851 (diff) | |
download | rspamd-4b22c83c6522476a160cb9ee07d5f21006c2e70b.tar.gz rspamd-4b22c83c6522476a160cb9ee07d5f21006c2e70b.zip |
Merge pull request #3866 from HeinleinSupport/lua_scanners/common
[Fix] lua_scanners - message_min_words logic
-rw-r--r-- | lualib/lua_scanners/common.lua | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lualib/lua_scanners/common.lua b/lualib/lua_scanners/common.lua index bbad123f5..a92d923d0 100644 --- a/lualib/lua_scanners/common.lua +++ b/lualib/lua_scanners/common.lua @@ -157,21 +157,24 @@ local function message_not_too_small(task, content, rule) end local function message_min_words(task, rule) - if rule.text_part_min_words then - local text_parts_empty = false + if rule.text_part_min_words and tonumber(rule.text_part_min_words) > 0 then + local text_part_above_limit = false local text_parts = task:get_text_parts() local filter_func = function(p) - return p:get_words_count() <= tonumber(rule.text_part_min_words) + return p:get_words_count() >= tonumber(rule.text_part_min_words) end fun.each(function(p) - text_parts_empty = true - rspamd_logger.infox(task, '%s: #words is less then text_part_min_words: %s', - rule.log_prefix, rule.text_part_min_words) + text_part_above_limit = true end, fun.filter(filter_func, text_parts)) - return text_parts_empty + if not text_part_above_limit then + rspamd_logger.infox(task, '%s: #words in all text parts is below text_part_min_words limit: %s', + rule.log_prefix, rule.text_part_min_words) + end + + return text_part_above_limit else return true end |