1
0
mirror of https://github.com/Uberi/Minetest-WorldEdit.git synced 2024-12-25 02:00:39 +01:00

Call minetest.deserialize with safe=true

wtf?
This commit is contained in:
sfan5 2020-02-06 11:53:14 +01:00
parent ab93871877
commit da51c688d2

View File

@ -119,7 +119,7 @@ end
local function deserialize_workaround(content) local function deserialize_workaround(content)
local nodes local nodes
if not jit then if not jit then
nodes = minetest.deserialize(content) nodes = minetest.deserialize(content, true)
else else
-- XXX: This is a filthy hack that works surprisingly well -- XXX: This is a filthy hack that works surprisingly well
-- in LuaJIT, `minetest.deserialize` will fail due to the register limit -- in LuaJIT, `minetest.deserialize` will fail due to the register limit
@ -135,11 +135,11 @@ local function deserialize_workaround(content)
break break
end end
local current = content:sub(startpos1, startpos) local current = content:sub(startpos1, startpos)
local entry = minetest.deserialize("return " .. current) local entry = minetest.deserialize("return " .. current, true)
table.insert(nodes, entry) table.insert(nodes, entry)
startpos, startpos1 = endpos, endpos startpos, startpos1 = endpos, endpos
end end
local entry = minetest.deserialize("return " .. content:sub(startpos1)) -- process the last entry local entry = minetest.deserialize("return " .. content:sub(startpos1), true) -- process the last entry
table.insert(nodes, entry) table.insert(nodes, entry)
end end
return nodes return nodes
@ -151,7 +151,7 @@ local function load_schematic(value)
local version, header, content = worldedit.read_header(value) local version, header, content = worldedit.read_header(value)
local nodes = {} local nodes = {}
if version == 1 or version == 2 then -- Original flat table format if version == 1 or version == 2 then -- Original flat table format
local tables = minetest.deserialize(content) local tables = minetest.deserialize(content, true)
if not tables then return nil end if not tables then return nil end
-- Transform the node table into an array of nodes -- Transform the node table into an array of nodes