diff options
author | Kim Alvefur <zash@zash.se> | 2014-09-17 14:50:00 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2014-09-17 14:50:00 +0200 |
commit | cd0acc10f7e3c4032367229c329cb131d739d0b0 (patch) | |
tree | 227868031630daa41352c6887c42c381081d8002 /prosody | |
parent | 93a297bc8ffd909ff006d664e1e824d8a9307cba (diff) | |
download | prosody-cd0acc10f7e3c4032367229c329cb131d739d0b0.tar.gz prosody-cd0acc10f7e3c4032367229c329cb131d739d0b0.zip |
prosody: Fix getfenv replacement for Lua 5.2
Diffstat (limited to 'prosody')
-rwxr-xr-x | prosody | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -153,7 +153,12 @@ function sandbox_require() local _real_require = require; if not getfenv then -- FIXME: This is a hack to replace getfenv() in Lua 5.2 - function getfenv(f) return debug.getupvalue(debug.getinfo(f or 1).func, 1); end + function getfenv(f) + local name, env = debug.getupvalue(debug.getinfo(f or 1).func, 1); + if name == "_ENV" then + return env; + end + end end function require(...) local curr_env = getfenv(2); |