diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-05-11 15:21:22 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-05-11 15:21:22 +0100 |
commit | deda62a64f558f38a89f2d93b9797a5f91693534 (patch) | |
tree | bea21d06610f6396324476764bf65406bfd3ab0a | |
parent | c62f291c138c795eb6f4ec8ce0e59204f5de3ca2 (diff) | |
download | rspamd-deda62a64f558f38a89f2d93b9797a5f91693534.tar.gz rspamd-deda62a64f558f38a89f2d93b9797a5f91693534.zip |
[Minor] Use numeric bit and for checking flags
-rw-r--r-- | rules/misc.lua | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/rules/misc.lua b/rules/misc.lua index 01a7c1f4b..b20f62bab 100644 --- a/rules/misc.lua +++ b/rules/misc.lua @@ -22,6 +22,9 @@ local util = require "rspamd_util" local rspamd_parsers = require "rspamd_parsers" local rspamd_regexp = require "rspamd_regexp" local rspamd_lua_utils = require "lua_util" +local bit = require "bit" +local rspamd_url = require "rspamd_url" +local url_flags_tab = rspamd_url.flags -- Different text parts rspamd_config.R_PARTS_DIFFER = { @@ -124,14 +127,16 @@ rspamd_config:register_symbol({ local obscured_id = rspamd_config:register_symbol{ callback = function(task) local urls = task:get_urls() + local obs_flag = url_flags_tab.obscured + local zw_flag = url_flags_tab.zw_spaces if urls then for _,u in ipairs(urls) do - local fl = u:get_flags() - if fl.obscured then + local fl = u:get_flags_num() + if bit.band(fl, obs_flag) then task:insert_result('R_SUSPICIOUS_URL', 1.0, u:get_host()) end - if fl.zw_spaces then + if bit.band(fl, zw_flag) then task:insert_result('ZERO_WIDTH_SPACE_URL', 1.0, u:get_host()) end end |