# HG changeset patch # User Kim Alvefur # Date 1413226924 -7200 # Node ID 67501b5576d36bb6929aacbec4d6cfe51d48b1df # Parent 3728c30da4e3543411b60c578527536fb0d0a364 prosody: Make getfenv() replacement for require() sandboxing local to avoid polluting the globals table diff -r 3728c30da4e3 -r 67501b5576d3 prosody --- a/prosody Wed Oct 08 18:42:33 2014 -0400 +++ b/prosody Mon Oct 13 21:02:04 2014 +0200 @@ -151,13 +151,11 @@ -- 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(...)