diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-01-29 13:21:20 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-01-29 13:21:20 +0000 |
commit | fb2c14b1e1eeb14b1d773b9a00f2ddceb8686327 (patch) | |
tree | f3852b87b7912bfe141256e114f41aa5a41056ef /rules/misc.lua | |
parent | c4e6bb9becc0db2d6a76de6a6faf2b011b089269 (diff) | |
download | rspamd-fb2c14b1e1eeb14b1d773b9a00f2ddceb8686327.tar.gz rspamd-fb2c14b1e1eeb14b1d773b9a00f2ddceb8686327.zip |
[Rules] OMOGRAPH_URL: Avoid extra calls for repeated urls
Diffstat (limited to 'rules/misc.lua')
-rw-r--r-- | rules/misc.lua | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/rules/misc.lua b/rules/misc.lua index 05d4af5d5..1cc7bfc22 100644 --- a/rules/misc.lua +++ b/rules/misc.lua @@ -373,26 +373,31 @@ rspamd_config.OMOGRAPH_URL = { local bad_omographs = 0 local single_bad_omograps = 0 local bad_urls = {} + local seen = {} fun.each(function(u) if u:is_phished() then + local h1 = u:get_host() local h2 = u:get_phished():get_host() if h1 and h2 then - if util.is_utf_spoofed(h1, h2) then - table.insert(bad_urls, string.format('%s->%s', h1, h2)) + local selt = string.format('%s->%s', h1, h2) + if not seen[selt] and util.is_utf_spoofed(h1, h2) then + bad_urls[#bad_urls + 1] = selt bad_omographs = bad_omographs + 1 end + seen[selt] = true end end if not u:is_html_displayed() then local h = u:get_tld() if h then - if util.is_utf_spoofed(h) then - table.insert(bad_urls, string.format('%s', h)) + if not seen[h] and util.is_utf_spoofed(h) then + bad_urls[#bad_urls + 1] = h single_bad_omograps = single_bad_omograps + 1 end + seen[h] = true end end end, urls) |