diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-09-28 11:05:12 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-09-28 11:05:12 +0100 |
commit | a0f7afdc2c97c742a92fd77bd3927b0c8fa422c7 (patch) | |
tree | 3f01578b4739b51881568c382331d4982a06a90f /lualib/lua_fuzzy.lua | |
parent | be2dc6559fe86c9e8c2071b4f5720df6d6bb9a55 (diff) | |
download | rspamd-a0f7afdc2c97c742a92fd77bd3927b0c8fa422c7.tar.gz rspamd-a0f7afdc2c97c742a92fd77bd3927b0c8fa422c7.zip |
[Fix] Fuzzy_check: Disable shingles for short texts (really)
Diffstat (limited to 'lualib/lua_fuzzy.lua')
-rw-r--r-- | lualib/lua_fuzzy.lua | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lualib/lua_fuzzy.lua b/lualib/lua_fuzzy.lua index d2733d5d6..0131ef8e2 100644 --- a/lualib/lua_fuzzy.lua +++ b/lualib/lua_fuzzy.lua @@ -157,14 +157,18 @@ local function check_text_part(task, part, rule, text) if rule.text_shingles then -- Check number of words - if rule.min_length > 0 and wcnt < rule.min_length then + local min_words = rule.min_length or 0 + if min_words < 32 then + min_words = 32 -- Minimum for shingles + end + if wcnt < min_words then lua_util.debugm(N, task, 'text has less than %s words: %s; disable shingles', rule.min_length, wcnt) allow_shingles = false else lua_util.debugm(N, task, 'allow shingles in text %s, %s words', id, wcnt) - allow_shingles = wcnt > 0 + allow_shingles = true end if not rule.short_text_direct_hash and not allow_shingles then @@ -191,7 +195,7 @@ end local function has_sane_text_parts(task) local text_parts = task:get_text_parts() or {} - return fun.any(function(tp) return tp:get_words_count() > 10 end, text_parts) + return fun.any(function(tp) return tp:get_words_count() > 32 end, text_parts) end local function check_image_part(task, part, rule, image) |