From 0c9fe6a9aaf65f86f28f874583ced55d3c6c50fe Mon Sep 17 00:00:00 2001 From: Lejo Date: Fri, 3 Jan 2020 12:01:23 +0100 Subject: [PATCH] Use safe_string_spit function --- mesecons_luacontroller/init.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua index a50c3a6..563ea0d 100644 --- a/mesecons_luacontroller/init.lua +++ b/mesecons_luacontroller/init.lua @@ -231,6 +231,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 @@ -463,7 +473,7 @@ local function create_environment(pos, mem, event, itbl, send_warning) reverse = string.reverse, sub = string.sub, find = safe_string_find, - split = string.split, + split = safe_string_split, }, math = { abs = math.abs,