mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-12-25 09:50:19 +01:00
Luacontroller: Revert function stripping from digiline messages
This commit is contained in:
parent
c2e3d7c4e5
commit
54daee236e
@ -151,24 +151,6 @@ function mesecon.tablecopy(table) -- deep table copy
|
|||||||
return newtable
|
return newtable
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.tablecopy_stripfunctions(table) -- deep table copy, but remove all functions
|
|
||||||
if type(table) == "function" then return nil end -- functions become nil
|
|
||||||
if type(table) ~= "table" then return table end -- no need to copy
|
|
||||||
local newtable = {}
|
|
||||||
|
|
||||||
for idx, item in pairs(table) do
|
|
||||||
if type(idx) ~= "function" then
|
|
||||||
if type(item) == "table" then
|
|
||||||
newtable[idx] = mesecon.tablecopy_stripfunctions(item)
|
|
||||||
elseif type(item) ~= "function" then
|
|
||||||
newtable[idx] = item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return newtable
|
|
||||||
end
|
|
||||||
|
|
||||||
function mesecon.cmpAny(t1, t2)
|
function mesecon.cmpAny(t1, t2)
|
||||||
if type(t1) ~= type(t2) then return false end
|
if type(t1) ~= type(t2) then return false end
|
||||||
if type(t1) ~= "table" and type(t2) ~= "table" then return t1 == t2 end
|
if type(t1) ~= "table" and type(t2) ~= "table" then return t1 == t2 end
|
||||||
|
@ -278,9 +278,11 @@ local function get_digiline_send(pos)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- No sending functions over the wire and make sure serialized version
|
-- It is technically possible to send functions over the wire since
|
||||||
-- of the data is not insanely long to prevent DoS-like attacks
|
-- the high performance impact of stripping those from the data has
|
||||||
msg = mesecon.tablecopy_stripfunctions(msg)
|
-- been decided to not be worth the added realism.
|
||||||
|
-- Make sure serialized version of the data is not insanely long to
|
||||||
|
-- prevent DoS-like attacks
|
||||||
local msg_ser = minetest.serialize(msg)
|
local msg_ser = minetest.serialize(msg)
|
||||||
if #msg_ser > mesecon.setting("luacontroller_digiline_maxlen", 50000) then
|
if #msg_ser > mesecon.setting("luacontroller_digiline_maxlen", 50000) then
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user