diff options
author | Andrew Lewis <nerf@judo.za.org> | 2017-07-10 10:18:21 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2017-07-10 10:18:21 +0200 |
commit | 74dfbe19122c902733405cc158368a967aa66a4f (patch) | |
tree | d1e31a836d0c8cf6b2316f9de58b64fc96a3bb0a /rules | |
parent | cadf3073d1ad7d100bd8cd31059d8c2886c03d5b (diff) | |
download | rspamd-74dfbe19122c902733405cc158368a967aa66a4f.tar.gz rspamd-74dfbe19122c902733405cc158368a967aa66a4f.zip |
[Fix] WHITE_ON_WHITE: Ensure score is matched to part that fired the rule
Diffstat (limited to 'rules')
-rw-r--r-- | rules/html.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/rules/html.lua b/rules/html.lua index 85eea48df..d240c836a 100644 --- a/rules/html.lua +++ b/rules/html.lua @@ -175,6 +175,7 @@ rspamd_config.R_WHITE_ON_WHITE = { local diff = 0.0 local normal_len = 0 local transp_len = 0 + local transp_rate = 0 local arg for _,p in ipairs(tp) do -- iterate over text parts array using `ipairs` @@ -200,7 +201,9 @@ rspamd_config.R_WHITE_ON_WHITE = { transp_len = (transp_len + tag:get_content_length()) * (0.1 - diff) * 5.0 normal_len = normal_len - tag:get_content_length() - if not arg then + local tr = transp_len / (normal_len + transp_len) + if tr > transp_rate then + transp_rate = tr arg = string.format('%s color #%x%x%x bgcolor #%x%x%x', tostring(tag:get_type()), color[1], color[2], color[3], @@ -217,9 +220,6 @@ 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 return true,(transp_rate * 2.0),arg end |