瀏覽代碼

[Fix] Adjust length of the fuzzy checks for short text parts

Reported by: @citrin
tags/3.3
Vsevolod Stakhov 1 年之前
父節點
當前提交
2249d428bd
沒有連結到貢獻者的電子郵件帳戶。
共有 2 個檔案被更改,包括 6 行新增6 行删除
  1. 5
    1
      lualib/lua_fuzzy.lua
  2. 1
    5
      src/lua/lua_mimepart.c

+ 5
- 1
lualib/lua_fuzzy.lua 查看文件

@@ -126,7 +126,11 @@ local function check_length(task, part, rule)
local adjusted_bytes = bytes

if part:is_text() then
bytes = part:get_text():get_length()
-- Fuzzy plugin uses stripped utf content to get an exact hash, that
-- corresponds to `get_content_oneline()`
-- However, in the case of empty parts this method returns `nil`, so extra
-- sanity check is required.
bytes = #(part:get_text():get_content_oneline() or '')
if rule.text_multiplier then
adjusted_bytes = bytes * rule.text_multiplier
end

+ 1
- 5
src/lua/lua_mimepart.c 查看文件

@@ -803,11 +803,7 @@ lua_textpart_get_content_oneline (lua_State * L)
return 1;
}

t = lua_newuserdata (L, sizeof (*t));
rspamd_lua_setclass (L, "rspamd{text}", -1);
t->start = part->utf_stripped_content->data;
t->len = part->utf_stripped_content->len;
t->flags = 0;
lua_new_text(L, part->utf_stripped_content->data, part->utf_stripped_content->len, FALSE);

return 1;
}

Loading…
取消
儲存