diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-05-06 22:42:18 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-05-06 22:42:18 +0100 |
commit | 9d5a725bd691c385f9eb456c4f07440c0b518380 (patch) | |
tree | 13e6f4c69f4fb9cf2f0e88a2481024f82100eb1a /lualib/lua_magic/heuristics.lua | |
parent | 24054b0a095953c6577d7f89ad4686de71345fea (diff) | |
download | rspamd-9d5a725bd691c385f9eb456c4f07440c0b518380.tar.gz rspamd-9d5a725bd691c385f9eb456c4f07440c0b518380.zip |
[Minor] Sigh, another condition fix
Diffstat (limited to 'lualib/lua_magic/heuristics.lua')
-rw-r--r-- | lualib/lua_magic/heuristics.lua | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lualib/lua_magic/heuristics.lua b/lualib/lua_magic/heuristics.lua index d977596ca..fc7743896 100644 --- a/lualib/lua_magic/heuristics.lua +++ b/lualib/lua_magic/heuristics.lua @@ -329,11 +329,11 @@ exports.text_part_heuristic = function(part, log_obj, _) local function is_span_text(span) -- We examine 8 bit content, and we assume it might be localized text -- if it has more than 3 subsequent 8 bit characters - local function rough_8bit_check(bytes, idx, remain) + local function rough_8bit_check(bytes, idx, remain, len) local b = bytes[idx] local n8bit = 0 - while b >= 127 and idx < remain do + while b >= 127 and idx <= len do -- utf8 part if bit.band(b, 0xe0) == 0xc0 and remain > 1 and bit.band(bytes[idx + 1], 0xc0) == 0x80 then @@ -372,7 +372,7 @@ exports.text_part_heuristic = function(part, log_obj, _) if (b < 0x20) and not (b == 0x0d or b == 0x0a or b == 0x09) then non_printable = non_printable + 1 elseif b >= 127 then - local c,nskip = rough_8bit_check(bytes, i, tlen - i) + local c,nskip = rough_8bit_check(bytes, i, tlen - i, tlen) if not c then non_printable = non_printable + 1 |