mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-18 14:15:12 +00:00
Remove string metatable protection
The string metatable and environment are no longer shared, so this sandboxing is no longer required.
This commit is contained in:
@@ -144,39 +144,6 @@ if _VERSION == "Lua 5.3" then
|
|||||||
]] )()
|
]] )()
|
||||||
end
|
end
|
||||||
|
|
||||||
if string.find( _HOST, "ComputerCraft" ) == 1 then
|
|
||||||
-- Prevent access to metatables or environments of strings, as these are global between all computers
|
|
||||||
local nativegetmetatable = getmetatable
|
|
||||||
local nativeerror = error
|
|
||||||
local nativetype = type
|
|
||||||
local string_metatable = nativegetmetatable("")
|
|
||||||
function getmetatable( t )
|
|
||||||
local mt = nativegetmetatable( t )
|
|
||||||
if mt == string_metatable then
|
|
||||||
nativeerror( "Attempt to access string metatable", 2 )
|
|
||||||
else
|
|
||||||
return mt
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if _VERSION == "Lua 5.1" and not _CC_DISABLE_LUA51_FEATURES then
|
|
||||||
local string_env = nativegetfenv(("").gsub)
|
|
||||||
function getfenv( env )
|
|
||||||
if env == nil then
|
|
||||||
env = 2
|
|
||||||
elseif nativetype( env ) == "number" and env > 0 then
|
|
||||||
env = env + 1
|
|
||||||
end
|
|
||||||
local fenv = nativegetfenv(env)
|
|
||||||
if fenv == string_env then
|
|
||||||
--nativeerror( "Attempt to access string metatable", 2 )
|
|
||||||
return nativegetfenv( 0 )
|
|
||||||
else
|
|
||||||
return fenv
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Install lua parts of the os api
|
-- Install lua parts of the os api
|
||||||
function os.version()
|
function os.version()
|
||||||
return "CraftOS 1.8"
|
return "CraftOS 1.8"
|
||||||
|
|||||||
Reference in New Issue
Block a user