From 58c91153514c6e07ba3bed20473a92d87ddd3ca5 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 13 Dec 2021 16:34:55 +0100 Subject: util.format: Ensure metatable __tostring results are also sanitized --- tools/generate_format_spec.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tools') 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)); -- cgit v1.2.3