From: Kim Alvefur Date: Wed, 17 Sep 2014 12:50:00 +0000 (+0200) Subject: prosody: Fix getfenv replacement for Lua 5.2 X-Git-Url: https://git.enpas.org/?a=commitdiff_plain;h=1f2af4f06da4e9b07f928bc835114d6e16508e39;p=prosody.git prosody: Fix getfenv replacement for Lua 5.2 --- 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);