mirror of
https://github.com/kikito/lua-sandbox.git
synced 2024-12-18 03:04:20 +00:00
fix(sandbox) fix false on passed_env
passed_env[k] = false would set BASE_ENV[k]
This commit is contained in:
parent
e28e0bef65
commit
26553beec7
@ -134,7 +134,11 @@ function sandbox.protect(code, options)
|
|||||||
local env = {}
|
local env = {}
|
||||||
for k, v in pairs(BASE_ENV) do
|
for k, v in pairs(BASE_ENV) do
|
||||||
local pv = passed_env[k]
|
local pv = passed_env[k]
|
||||||
env[k] = pv ~= nil and pv or v
|
if pv ~= nil then
|
||||||
|
env[k] = pv
|
||||||
|
else
|
||||||
|
env[k] = v
|
||||||
|
end
|
||||||
end
|
end
|
||||||
setmetatable(env, { __index = options.env })
|
setmetatable(env, { __index = options.env })
|
||||||
env._G = env
|
env._G = env
|
||||||
|
Loading…
Reference in New Issue
Block a user