aboutsummaryrefslogtreecommitdiff
path: root/builtin/common
diff options
context:
space:
mode:
authorLars Müller <34514239+appgurueu@users.noreply.github.com>2022-07-14 20:50:21 +0200
committerGitHub <noreply@github.com>2022-07-14 20:50:21 +0200
commitac4eb746fe9da775a8bffe825a868581c0353169 (patch)
tree0f6ed4bfec89734b2168e8af24e545043b411de6 /builtin/common
parent6df69f9b5bea5b438498bbae7e9873bb99434439 (diff)
downloadminetest-ac4eb746fe9da775a8bffe825a868581c0353169.tar.gz
minetest-ac4eb746fe9da775a8bffe825a868581c0353169.tar.bz2
minetest-ac4eb746fe9da775a8bffe825a868581c0353169.zip
Deserialization: Restore backwards compat (#12519)
Diffstat (limited to 'builtin/common')
-rw-r--r--builtin/common/serialize.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/builtin/common/serialize.lua b/builtin/common/serialize.lua
index 6278e2739..caf989e69 100644
--- a/builtin/common/serialize.lua
+++ b/builtin/common/serialize.lua
@@ -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