Activate minetest.deserialize safety

This commit is contained in:
Wuzzy 2024-09-09 23:23:10 +02:00
parent 84b1cdd2c8
commit 3978b14a29

View File

@ -1,7 +1,7 @@
playerphysics = {} playerphysics = {}
local function calculate_attribute_product(player, attribute) local function calculate_attribute_product(player, attribute)
local a = minetest.deserialize(player:get_meta():get_string("playerphysics:physics")) local a = minetest.deserialize(player:get_meta():get_string("playerphysics:physics"), true)
local product = 1 local product = 1
if a == nil or a[attribute] == nil then if a == nil or a[attribute] == nil then
return product return product
@ -17,7 +17,7 @@ end
function playerphysics.add_physics_factor(player, attribute, id, value) function playerphysics.add_physics_factor(player, attribute, id, value)
local meta = player:get_meta() local meta = player:get_meta()
local a = minetest.deserialize(meta:get_string("playerphysics:physics")) local a = minetest.deserialize(meta:get_string("playerphysics:physics"), true)
if a == nil then if a == nil then
a = { [attribute] = { [id] = value } } a = { [attribute] = { [id] = value } }
elseif a[attribute] == nil then elseif a[attribute] == nil then
@ -32,7 +32,7 @@ end
function playerphysics.remove_physics_factor(player, attribute, id) function playerphysics.remove_physics_factor(player, attribute, id)
local meta = player:get_meta() local meta = player:get_meta()
local a = minetest.deserialize(meta:get_string("playerphysics:physics")) local a = minetest.deserialize(meta:get_string("playerphysics:physics"), true)
if a == nil or a[attribute] == nil then if a == nil or a[attribute] == nil then
-- Nothing to remove -- Nothing to remove
return return
@ -46,7 +46,7 @@ end
function playerphysics.get_physics_factor(player, attribute, id) function playerphysics.get_physics_factor(player, attribute, id)
local meta = player:get_meta() local meta = player:get_meta()
local a = minetest.deserialize(meta:get_string("playerphysics:physics")) local a = minetest.deserialize(meta:get_string("playerphysics:physics"), true)
if a == nil then if a == nil then
return nil return nil
elseif a[attribute] == nil then elseif a[attribute] == nil then