commit deda62a: [Minor] Use numeric bit and for checking flags

Vsevolod Stakhov vsevolod at highsecure.ru
Tue May 11 14:28:05 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-05-11 15:21:22 +0100
URL: https://github.com/rspamd/rspamd/commit/deda62a64f558f38a89f2d93b9797a5f91693534 (HEAD -> master)

[Minor] Use numeric bit and for checking flags

---
 rules/misc.lua | 11 ++++++++---
 1 file 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


More information about the Commits mailing list