diff options
author | Kim Alvefur <zash@zash.se> | 2014-10-13 21:02:04 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2014-10-13 21:02:04 +0200 |
commit | 887f411c4e018eb2ac034e80c6477d2cd253f729 (patch) | |
tree | ab386a9e59163f1cc2cfa87acd44184a1f8912b3 | |
parent | e8dcccf0b5e0837c906e28fcc6a43a88586d9a29 (diff) | |
download | prosody-887f411c4e018eb2ac034e80c6477d2cd253f729.tar.gz prosody-887f411c4e018eb2ac034e80c6477d2cd253f729.zip |
prosody: Make getfenv() replacement for require() sandboxing local to avoid polluting the globals table
-rwxr-xr-x | prosody | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -151,13 +151,11 @@ function sandbox_require() -- for neat sandboxing of modules local _realG = _G; local _real_require = require; - if not getfenv then + local getfenv = getfenv or function (f) -- FIXME: This is a hack to replace getfenv() in Lua 5.2 - function getfenv(f) - local name, env = debug.getupvalue(debug.getinfo(f or 1).func, 1); - if name == "_ENV" then - return env; - end + local name, env = debug.getupvalue(debug.getinfo(f or 1).func, 1); + if name == "_ENV" then + return env; end end function require(...) |