Skip to content

Commit 85a0959

Browse files
add string.split
see minetest-mods/mesecons#500
1 parent 607db13 commit 85a0959

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

controller.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,16 @@ local function get_digiline_send(pos, itbl, send_warning)
461461
end
462462
end
463463

464+
-- do not allow pattern matching in string.split (see string.find for details)
465+
local function safe_string_split(...)
466+
if select(5, ...) then
467+
debug.sethook() -- Clear hook
468+
error("string.split: 'sep_is_pattern' (fifth parameter) may not be used in a Luacontroller")
469+
end
470+
471+
return string.split(...)
472+
end
473+
464474
local safe_globals = {
465475
-- Don't add pcall/xpcall unless willing to deal with the consequences (unless very careful, incredibly likely to allow killing server indirectly)
466476
"assert", "error", "ipairs", "next", "pairs", "select",
@@ -503,6 +513,7 @@ local function create_environment(pos, mem, event, itbl, send_warning)
503513
reverse = string.reverse,
504514
sub = string.sub,
505515
find = safe_string_find,
516+
split = safe_string_split
506517
},
507518
math = {
508519
abs = math.abs,

0 commit comments

Comments
 (0)