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) ...@@ -55,6 +55,14 @@ function escape(s)
return (string.gsub(s,"([%^%$%%%.%[%]%*%+%-%?])","%%%1")) return (string.gsub(s,"([%^%$%%%.%[%]%*%+%-%?])","%%%1"))
end 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) function process_raw(filename)
local input = io.open(filename):read("*a") local input = io.open(filename):read("*a")
-- find the longest [===[ or ]=====] type sequence and make sure that -- find the longest [===[ or ]=====] type sequence and make sure that
...@@ -77,7 +85,7 @@ function process_raw(filename) ...@@ -77,7 +85,7 @@ function process_raw(filename)
io.write("\n") io.write("\n")
end end
--]] --]]
return assert(loadstring(code,filename)) return assert(my_vlc_load(code,filename))
end end
function process(filename) function process(filename)
......
...@@ -34,7 +34,6 @@ local sandbox_blacklist = { ...@@ -34,7 +34,6 @@ local sandbox_blacklist = {
getmetatable = true, getmetatable = true,
load = true, -- Can be protected I guess load = true, -- Can be protected I guess
loadfile = true, -- Can be protected I guess loadfile = true, -- Can be protected I guess
loadstring = true, -- Can be protected I guess
rawequal = true, rawequal = true,
rawget = true, rawget = true,
rawset = true, rawset = true,
...@@ -46,6 +45,10 @@ local sandbox_blacklist = { ...@@ -46,6 +45,10 @@ local sandbox_blacklist = {
debug = true, debug = true,
} }
if _VERSION == "Lua 5.1" then
sandbox_blacklist["loadstring"] = true
end
function readonly_table_proxy(name,src,blacklist) function readonly_table_proxy(name,src,blacklist)
if type(src)=="nil" then return end if type(src)=="nil" then return end
if type(src)~="table" then error("2nd argument must be a table (or nil)") end if type(src)~="table" then error("2nd argument must be a table (or nil)") 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