aboutsummaryrefslogtreecommitdiffstats
path: root/rules/html.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-08 14:21:17 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-08 14:21:17 +0100
commitb8132cfbab29d171ab3608161a6e64e881f205ec (patch)
treeebdbff5ededc3cab6e04483d94e5eaafde79a4c5 /rules/html.lua
parent842f6c31ca5d1a2154efcd8795ae7142f22d191c (diff)
downloadrspamd-b8132cfbab29d171ab3608161a6e64e881f205ec.tar.gz
rspamd-b8132cfbab29d171ab3608161a6e64e881f205ec.zip
[Fix] Some more fixes for low contrast fonts detector
Diffstat (limited to 'rules/html.lua')
-rw-r--r--rules/html.lua30
1 files changed, 11 insertions, 19 deletions
diff --git a/rules/html.lua b/rules/html.lua
index 1c4c86cdc..68eca3010 100644
--- a/rules/html.lua
+++ b/rules/html.lua
@@ -171,7 +171,8 @@ rspamd_config.R_WHITE_ON_WHITE = {
local ret = false
local diff = 0.0
local normal_len = 0
- local transp_tags = {}
+ local transp_len = 0
+ local arg
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
@@ -191,7 +192,14 @@ rspamd_config.R_WHITE_ON_WHITE = {
if diff < 0.2 then
ret = true
- table.insert(transp_tags, tag)
+ transp_len = (transp_len + tag:get_content_length()) *
+ (0.2 - diff) * 5.0
+ if not arg then
+ arg = string.format('%s color #%x%x%x bgcolor #%x%x%x',
+ tostring(tag:get_type()),
+ color[1], color[2], color[3],
+ bgcolor[1], bgcolor[2], bgcolor[3])
+ end
else
normal_len = normal_len + tag:get_content_length()
end
@@ -205,24 +213,8 @@ rspamd_config.R_WHITE_ON_WHITE = {
end
if ret then
- local transp_len = 0
- local arg
-
- for _,t in ipairs(transp_tags) do
- local bl = t:get_extra()
- local color = bl['color']
- local bgcolor = bl['bgcolor']
- transp_len = transp_len + t:get_content_length()
-
- if not arg then
- arg = string.format('%s color #%x%x%x bgcolor #%x%x%x',
- tostring(t:get_type()),
- color[1], color[2], color[3],
- bgcolor[1], bgcolor[2], bgcolor[3])
- end
- end
-
local transp_rate = transp_len / (normal_len + transp_len)
+
if transp_rate > 0.1 then
return true,(transp_rate * 2.0),arg
end