aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-12-13 16:34:55 +0100
committerKim Alvefur <zash@zash.se>2021-12-13 16:34:55 +0100
commit58c91153514c6e07ba3bed20473a92d87ddd3ca5 (patch)
tree87f8f4755afc8ba49eeabeca279898ab9260e632 /tools
parent283042d7c3ae7e7b25a51e71be736c84a71a0bd7 (diff)
downloadprosody-58c91153514c6e07ba3bed20473a92d87ddd3ca5.tar.gz
prosody-58c91153514c6e07ba3bed20473a92d87ddd3ca5.zip
util.format: Ensure metatable __tostring results are also sanitized
Diffstat (limited to 'tools')
-rw-r--r--tools/generate_format_spec.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/generate_format_spec.lua b/tools/generate_format_spec.lua
index f5902327..359986f7 100644
--- a/tools/generate_format_spec.lua
+++ b/tools/generate_format_spec.lua
@@ -18,13 +18,14 @@ local example_values = {
["function"] = { function() end };
-- ["userdata"] = {};
["thread"] = { coroutine.create(function() end) };
- ["table"] = { {} };
+ ["table"] = { {}, setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end}) };
};
local example_strings = setmetatable({
["nil"] = { "nil" };
["function"] = { "function() end" };
["number"] = { "97"; "-12345"; "1.5"; "73786976294838206464"; "math.huge"; "2147483647" };
["thread"] = { "coroutine.create(function() end)" };
+ ["table"] = { "{ }", "setmetatable({},{__tostring=function ()return \"foo \\1\\2\\3 bar\"end})" }
}, { __index = function() return {} end });
for _, lua_type in ipairs(types) do
print(string.format("\t\tdescribe(\"%s\", function ()", lua_type));