]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
fixup! sandbox: table_print sorts table keys
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 10 Apr 2019 11:44:59 +0000 (13:44 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Wed, 10 Apr 2019 12:23:07 +0000 (14:23 +0200)
daemon/lua/sandbox.lua.in

index 14ada7f64209be4c4452460516c03d629ec1b887..33da8ca96eb821738dc97cf505fb0e6e8c566c94 100644 (file)
@@ -396,13 +396,13 @@ function table_print (tt, indent, done)
        done = done or {}
        indent = indent or 0
        local result = ""
-       -- Convert to printable string (escape unprintable)
+       -- Ordered for-iterator for tables with tostring-able keys.
        local function ordered_iter(unordered_tt)
                local keys = {}
                for k in pairs(unordered_tt) do
-                       table.insert(keys, tostring(k))
+                       table.insert(keys, k)
                end
-               table.sort(keys)
+               table.sort(keys, function (a, b) return tostring(a) < tostring(b) end)
                local i = 0
                return function()
                        i = i + 1
@@ -411,6 +411,7 @@ function table_print (tt, indent, done)
                        end
                end
        end
+       -- Convert to printable string (escape unprintable)
        local function printable(value)
                value = tostring(value)
                local bytes = {}