Deserialization: Restore backwards compat (#12519)

This commit is contained in:
Lars Müller 2022-07-14 20:50:21 +02:00 committed by GitHub
parent 6df69f9b5b
commit ac4eb746fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -188,6 +188,16 @@ local function dummy_func() end
local nan = (0/0)^1 -- +nan
function core.deserialize(str, safe)
-- Backwards compatibility
if str == nil then
core.log("deprecated", "minetest.deserialize called with nil (expected string).")
return nil, "Invalid type: Expected a string, got nil"
end
local t = type(str)
if t ~= "string" then
error(("minetest.deserialize called with %s (expected string)."):format(t))
end
local func, err = loadstring(str)
if not func then return nil, err end