Deserialization: Restore backwards compat (#12519)

master
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
1 changed files with 10 additions and 0 deletions

View File

@ -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