]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Selectors: Properly fix implicit tostring for nils
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 25 Feb 2021 12:42:38 +0000 (12:42 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 25 Feb 2021 12:42:38 +0000 (12:42 +0000)
lualib/lua_selectors/init.lua

index cc44d0b017d4ac7dc3602ee9f86fffba29faf455..e971e14c3f2fd12f2f9d6c08a2c656e1dd7b8207 100644 (file)
@@ -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'