From ac4eb746fe9da775a8bffe825a868581c0353169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20M=C3=BCller?= <34514239+appgurueu@users.noreply.github.com> Date: Thu, 14 Jul 2022 20:50:21 +0200 Subject: [PATCH] Deserialization: Restore backwards compat (#12519) --- builtin/common/serialize.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) 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