fix(sandbox) fix false on passed_env

passed_env[k] = false would set BASE_ENV[k]
This commit is contained in:
eskerda 2021-01-07 17:12:10 +01:00 committed by Enrique García Cota
parent e28e0bef65
commit 26553beec7

View File

@ -134,7 +134,11 @@ function sandbox.protect(code, options)
local env = {}
for k, v in pairs(BASE_ENV) do
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
setmetatable(env, { __index = options.env })
env._G = env