Skip to content

Commit 54daee2

Browse files
committedJan 15, 2017
Luacontroller: Revert function stripping from digiline messages
1 parent c2e3d7c commit 54daee2

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed
 

‎mesecons/util.lua

-18
Original file line numberDiff line numberDiff line change
@@ -151,24 +151,6 @@ function mesecon.tablecopy(table) -- deep table copy
151151
return newtable
152152
end
153153

154-
function mesecon.tablecopy_stripfunctions(table) -- deep table copy, but remove all functions
155-
if type(table) == "function" then return nil end -- functions become nil
156-
if type(table) ~= "table" then return table end -- no need to copy
157-
local newtable = {}
158-
159-
for idx, item in pairs(table) do
160-
if type(idx) ~= "function" then
161-
if type(item) == "table" then
162-
newtable[idx] = mesecon.tablecopy_stripfunctions(item)
163-
elseif type(item) ~= "function" then
164-
newtable[idx] = item
165-
end
166-
end
167-
end
168-
169-
return newtable
170-
end
171-
172154
function mesecon.cmpAny(t1, t2)
173155
if type(t1) ~= type(t2) then return false end
174156
if type(t1) ~= "table" and type(t2) ~= "table" then return t1 == t2 end

‎mesecons_luacontroller/init.lua

+5-3
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,11 @@ local function get_digiline_send(pos)
278278
return false
279279
end
280280

281-
-- No sending functions over the wire and make sure serialized version
282-
-- of the data is not insanely long to prevent DoS-like attacks
283-
msg = mesecon.tablecopy_stripfunctions(msg)
281+
-- It is technically possible to send functions over the wire since
282+
-- the high performance impact of stripping those from the data has
283+
-- been decided to not be worth the added realism.
284+
-- Make sure serialized version of the data is not insanely long to
285+
-- prevent DoS-like attacks
284286
local msg_ser = minetest.serialize(msg)
Has conversations. Original line has conversations.
285287
if #msg_ser > mesecon.setting("luacontroller_digiline_maxlen", 50000) then
286288
return false

0 commit comments

Comments
 (0)
Please sign in to comment.