]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Deduct type of a table methods
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 13 Nov 2020 11:29:41 +0000 (11:29 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 13 Nov 2020 11:30:00 +0000 (11:30 +0000)
lualib/lua_selectors/init.lua

index 8de79f7679ba15ded7e300dad16254f022bc3295..54d42f2428b4a5ff73524b1fb1602bcb80b94e62 100644 (file)
@@ -338,20 +338,24 @@ exports.parse_selector = function(cfg, str)
           },
           map_type = 'string',
           process = function(inp, t, args)
+            local ret
             if t == 'table' then
-              return inp[method_name],'string'
+              -- Plain table field
+              ret = inp[method_name]
             else
               -- We call method unpacking arguments and dropping all but the first result returned
-              local ret = (inp[method_name](inp, unpack_function(args or E)))
-              local ret_type = type(ret)
-              -- Now apply types heuristic
-              if ret_type == 'string' then
-                return ret,'string'
-              elseif ret_type == 'table' then
-                return ret,'string_list'
-              else
-                return implicit_tostring(ret_type, ret)
-              end
+              ret = (inp[method_name](inp, unpack_function(args or E)))
+            end
+
+            local ret_type = type(ret)
+            -- Now apply types heuristic
+            if ret_type == 'string' then
+              return ret,'string'
+            elseif ret_type == 'table' then
+              -- TODO: we need to ensure that 1) table is numeric 2) table has merely strings
+              return ret,'string_list'
+            else
+              return implicit_tostring(ret_type, ret)
             end
           end,
         }