libs/core: properly handle udata values in overloaded string format operator
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 29 Jul 2009 04:29:22 +0000 (04:29 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 29 Jul 2009 04:29:22 +0000 (04:29 +0000)
libs/core/luasrc/util.lua

index 9747a448620abd478185f9d9ebe5312823a453d2..84c63f240409091588a09821e970f2a4df70c7ea 100644 (file)
@@ -49,8 +49,10 @@ getmetatable("").__mod = function(a, b)
        if not b then
                return a
        elseif type(b) == "table" then
+               for k, _ in pairs(b) do if type(b[k]) == "userdata" then b[k] = tostring(b[k]) end end
                return a:format(unpack(b))
        else
+               if type(b) == "userdata" then b = tostring(b) end
                return a:format(b)
        end
 end