aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2014-09-17 14:50:00 +0200
committerKim Alvefur <zash@zash.se>2014-09-17 14:50:00 +0200
commit55217ae785781c5dc943e512278f8afdb868ed9a (patch)
tree227868031630daa41352c6887c42c381081d8002
parent3d4d1527111f5774ba1314e34daa986e49807a39 (diff)
downloadprosody-55217ae785781c5dc943e512278f8afdb868ed9a.tar.gz
prosody-55217ae785781c5dc943e512278f8afdb868ed9a.zip
prosody: Fix getfenv replacement for Lua 5.2
-rwxr-xr-xprosody7
1 files changed, 6 insertions, 1 deletions
diff --git a/prosody b/prosody
index 8fcee8e8..aab803c5 100755
--- a/prosody
+++ b/prosody
@@ -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);