Commit 58ad6be8 authored by Shlomi Fish's avatar Shlomi Fish Committed by Jean-Baptiste Kempf

lua: fix HTTP loadstring in lua 5.2+

Close #14988
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 167830d4
......@@ -55,6 +55,14 @@ function escape(s)
return (string.gsub(s,"([%^%$%%%.%[%]%*%+%-%?])","%%%1"))
end
function my_vlc_load(code, filename)
if _VERSION == "Lua 5.1" then
return loadstring(code, filename)
else
return load(code, filename)
end
end
function process_raw(filename)
local input = io.open(filename):read("*a")
-- find the longest [===[ or ]=====] type sequence and make sure that
......@@ -77,7 +85,7 @@ function process_raw(filename)
io.write("\n")
end
--]]
return assert(loadstring(code,filename))
return assert(my_vlc_load(code,filename))
end
function process(filename)
......
......@@ -34,7 +34,6 @@ local sandbox_blacklist = {
getmetatable = true,
load = true, -- Can be protected I guess
loadfile = true, -- Can be protected I guess
loadstring = true, -- Can be protected I guess
rawequal = true,
rawget = true,
rawset = true,
......@@ -46,6 +45,10 @@ local sandbox_blacklist = {
debug = true,
}
if _VERSION == "Lua 5.1" then
sandbox_blacklist["loadstring"] = true
end
function readonly_table_proxy(name,src,blacklist)
if type(src)=="nil" then return end
if type(src)~="table" then error("2nd argument must be a table (or nil)") end
......@@ -117,4 +120,4 @@ function sandbox(func,override)
setfenv(func,_G)
return unpack(ret)
end
end
\ No newline at end of file
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment