commit 4745be0: [Minor] Improve redirected urls processing in filter_specific_urls

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Aug 21 17:00:08 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-08-21 16:05:41 +0100
URL: https://github.com/rspamd/rspamd/commit/4745be02184e81354ae548b47c099b4a8d62e19e

[Minor] Improve redirected urls processing in filter_specific_urls

---
 lualib/lua_util.lua | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua
index 4dddb979f..4aa39db9b 100644
--- a/lualib/lua_util.lua
+++ b/lualib/lua_util.lua
@@ -681,27 +681,30 @@ exports.filter_specific_urls = function (urls, params)
     return false
   end
 
-  local function process_single_url(u)
-    local priority = 1 -- Normal priority
-    local esld = u:get_tld()
+  local function process_single_url(u, default_priority)
+    local priority = default_priority or 1 -- Normal priority
 
-    if params.ignore_redirected and u:is_redirected() then
+    if u:is_redirected() then
       local redir = u:get_redirected() -- get the real url
-      local redir_tld = redir:get_tld()
 
-      if redir_tld then
-        -- Ignore redirected as it should also be in the hash
-        return
+      if params.ignore_redirected then
+        -- Replace `u` with redir
+        u = redir
+        priority = 2
+      else
+        -- Process both redirected url and the original one
+        process_single_url(redir, 2)
       end
     end
 
+    local esld = u:get_tld()
     local str_hash = tostring(u)
 
     if esld then
       -- Special cases
       if (u:get_protocol() ~= 'mailto') and (not u:is_html_displayed()) then
         if u:is_obscured() then
-          priority = 2
+          priority = 3
         else
           if u:get_user() then
             priority = 2


More information about the Commits mailing list