Add string.split function (#500)

This commit is contained in:
Lejo 2023-06-18 20:43:53 +02:00 committed by GitHub
parent f98ea14023
commit fef402e88a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -238,6 +238,16 @@ local function safe_string_find(...)
return string.find(...)
end
-- do not allow pattern matching in string.split (see string.find for details)
local function safe_string_split(...)
if select(5, ...) then
debug.sethook() -- Clear hook
error("string.split: 'sep_is_pattern' (fifth parameter) may not be used in a Luacontroller")
end
return string.split(...)
end
local function remove_functions(x)
local tp = type(x)
if tp == "function" then
@ -507,6 +517,7 @@ local function create_environment(pos, mem, event, itbl, send_warning)
reverse = string.reverse,
sub = string.sub,
find = safe_string_find,
split = safe_string_split,
},
math = {
abs = math.abs,