diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-08-08 15:04:14 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-08-08 15:04:14 +0100 |
commit | d4dd679a8cba673e6d0beb2766380940325704ce (patch) | |
tree | 1d7dc2fb933adaa8142af44e4d94db53051fa5c6 /rules/html.lua | |
parent | 9d8b0258a4558aba1db3dda82b050a401f427c09 (diff) | |
download | rspamd-d4dd679a8cba673e6d0beb2766380940325704ce.tar.gz rspamd-d4dd679a8cba673e6d0beb2766380940325704ce.zip |
[Fix] Fix length calculations in white on white rule
Diffstat (limited to 'rules/html.lua')
-rw-r--r-- | rules/html.lua | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/rules/html.lua b/rules/html.lua index 68eca3010..2a807d07e 100644 --- a/rules/html.lua +++ b/rules/html.lua @@ -176,6 +176,7 @@ rspamd_config.R_WHITE_ON_WHITE = { for _,p in ipairs(tp) do -- iterate over text parts array using `ipairs` if p:is_html() then -- if the current part is html part + normal_len = p:get_length() local hc = p:get_html() -- we get HTML context hc:foreach_tag('font', function(tag, len) @@ -190,10 +191,11 @@ rspamd_config.R_WHITE_ON_WHITE = { local diff_b = math.abs(color[3] - bgcolor[3]) / 255.0 diff = (diff_r + diff_g + diff_b) / 3.0 - if diff < 0.2 then + if diff < 0.1 then ret = true transp_len = (transp_len + tag:get_content_length()) * - (0.2 - diff) * 5.0 + (0.1 - diff) * 5.0 + normal_len = normal_len - tag:get_content_length() if not arg then arg = string.format('%s color #%x%x%x bgcolor #%x%x%x', tostring(tag:get_type()), @@ -201,7 +203,7 @@ rspamd_config.R_WHITE_ON_WHITE = { bgcolor[1], bgcolor[2], bgcolor[3]) end else - normal_len = normal_len + tag:get_content_length() + end end end @@ -213,6 +215,7 @@ rspamd_config.R_WHITE_ON_WHITE = { end if ret then + if normal_len < 0 then normal_len = 0 end local transp_rate = transp_len / (normal_len + transp_len) if transp_rate > 0.1 then |