From: Vsevolod Stakhov Date: Tue, 11 May 2021 14:21:22 +0000 (+0100) Subject: [Minor] Use numeric bit and for checking flags X-Git-Tag: 3.0~420 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=deda62a64f558f38a89f2d93b9797a5f91693534;p=thirdparty%2Frspamd.git [Minor] Use numeric bit and for checking flags --- diff --git a/rules/misc.lua b/rules/misc.lua index 01a7c1f4b4..b20f62bab2 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