From: Kim Alvefur Date: Mon, 13 Oct 2014 19:02:04 +0000 (+0200) Subject: prosody: Make getfenv() replacement for require() sandboxing local to avoid polluting... X-Git-Url: https://git.enpas.org/?a=commitdiff_plain;h=697f097e01fe673c57d6111bb396da61fa1a4d21;p=prosody.git prosody: Make getfenv() replacement for require() sandboxing local to avoid polluting the globals table --- diff --git a/prosody b/prosody index aab803c5..e8f81d5d 100755 --- a/prosody +++ b/prosody @@ -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(...)