commit 0bb5930: [Fix] Selectors: Properly fix implicit tostring for nils

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Feb 25 12:49:06 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-02-25 12:42:38 +0000
URL: https://github.com/rspamd/rspamd/commit/0bb5930abfa451f72e0652acb6282c500c39f1ac (HEAD -> master)

[Fix] Selectors: Properly fix implicit tostring for nils

---
 lualib/lua_selectors/init.lua | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lualib/lua_selectors/init.lua b/lualib/lua_selectors/init.lua
index cc44d0b01..e971e14c3 100644
--- a/lualib/lua_selectors/init.lua
+++ b/lualib/lua_selectors/init.lua
@@ -64,9 +64,11 @@ local function implicit_tostring(t, ud_or_table)
     else
       return tostring(ud_or_table),'string'
     end
-  else
+  elseif t ~= 'nil' then
     return tostring(ud_or_table),'string'
   end
+
+  return nil
 end
 
 local function process_selector(task, sel)
@@ -350,6 +352,8 @@ exports.parse_selector = function(cfg, str)
             end
 
             local ret_type = type(ret)
+
+            if ret_type == 'nil' then return nil end
             -- Now apply types heuristic
             if ret_type == 'string' then
               return ret,'string'


More information about the Commits mailing list