]> git.lizzy.rs Git - minetest.git/commitdiff
Deserialization: Restore backwards compat (#12519)
authorLars Müller <34514239+appgurueu@users.noreply.github.com>
Thu, 14 Jul 2022 18:50:21 +0000 (20:50 +0200)
committerGitHub <noreply@github.com>
Thu, 14 Jul 2022 18:50:21 +0000 (20:50 +0200)
builtin/common/serialize.lua

index 6278e27393cc16d69f03e34517ef16c084b79334..caf989e69fd30218a17924fefe8def06e469d549 100644 (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