Mercurial > prosody-hg
diff tools/generate_format_spec.lua @ 12039:e0a8c5b1ab4f
util.format: Ensure metatable __tostring results are also sanitized
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 13 Dec 2021 16:34:55 +0100 |
| parents | 82f6a0b0a425 |
| children |
line wrap: on
line diff
--- a/tools/generate_format_spec.lua Sun Dec 12 18:38:40 2021 +0100 +++ b/tools/generate_format_spec.lua Mon Dec 13 16:34:55 2021 +0100 @@ -18,13 +18,14 @@ ["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));
