From 62c73abd1c2c75e93204875a0cb7be58c66273b4 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 13 Feb 2017 15:27:43 +0000 Subject: [PATCH] [Minor] Ignore displayed only urls from omographs check --- rules/misc.lua | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/rules/misc.lua b/rules/misc.lua index 408c3e732..d1bd8f9ca 100644 --- a/rules/misc.lua +++ b/rules/misc.lua @@ -788,30 +788,37 @@ rspamd_config:register_dependency(freemail_reply_neq_from_id, 'FREEMAIL_FROM') rspamd_config.OMOGRAPH_URL = { callback = function(task) + local fun = require "fun" local urls = task:get_urls() if urls then - for _,u in ipairs(urls) do - local h = u:get_host() + local bad_omographs = 0 + local bad_urls = {} + fun.each(function(u) + local h = u:get_host() if h then local parts = rspamd_str_split(h, '.') - - local bad_omographs = 0 + local found = false for _,p in ipairs(parts) do local cnlat,ctot = util.count_non_ascii(p) if cnlat > 0 and cnlat ~= ctot then bad_omographs = bad_omographs + 1.0 / cnlat + found = true end end - if bad_omographs > 0 then - if bad_omographs > 1 then bad_omographs = 1.0 end - return true, bad_omographs, h + if found then + table.insert(bad_urls, h) end end + end, fun.filter(function(u) return not u:is_html_displayed() end, urls)) + + if bad_omographs > 0 then + if bad_omographs > 1 then bad_omographs = 1.0 end + return true, bad_omographs, bad_urls end end -- 2.39.5