Skip to content

Commit

Permalink
Deserialization: Restore backwards compat (minetest#12519)
Browse files Browse the repository at this point in the history
  • Loading branch information
appgurueu committed Jul 14, 2022
1 parent 6df69f9 commit ac4eb74
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions builtin/common/serialize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ac4eb74

Please sign in to comment.