diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/supple/sandbox.lua | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/supple/sandbox.lua b/lib/supple/sandbox.lua index ab1d87a..3d9d93a 100644 --- a/lib/supple/sandbox.lua +++ b/lib/supple/sandbox.lua @@ -29,6 +29,7 @@ local loadstring = loadstring local load = load local setfenv = setfenv local gc = collectgarbage +local unpack = unpack local function set_limits(ltab) local count = ltab.count @@ -73,6 +74,17 @@ local function _wrap(fn, src, globs) return fn_ret, fn_glob end +local function wrapped_unpack(t) + local packed = t + if capi.rawtype(t) ~= "table" then + local len = #t + packed = {} + for i = 1, len do + packed[i] = t[i] + end + end + return unpack(packed) +end local function run() -- Run the sandbox @@ -106,10 +118,11 @@ local function run() pairs = capi.pairs, ipairs = capi.ipairs, next = capi.next, + unpack = wrapped_unpack, } for _, k in ipairs({ "table", "string", "pcall", - "xpcall", "unpack", "tostring", "tonumber", "math", + "xpcall", "tostring", "tonumber", "math", "coroutine", "select", "error", "assert" }) do sandbox_globals[k] = _G[k] end |