mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-03-14 15:38:13 +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:
parent
bb741975b7
commit
0420b6c831
@ -144,39 +144,6 @@ if _VERSION == "Lua 5.3" then
|
||||
]] )()
|
||||
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
|
||||
function os.version()
|
||||
return "CraftOS 1.8"
|
||||
|
Loading…
x
Reference in New Issue
Block a user