Compare commits
4
Commits
git-release
...
v0.27.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d893bebdc | ||
|
|
011b9dc46a | ||
|
|
83299b8382 | ||
|
|
899ce94693 |
No files matched your search
@@ -1,3 +1,12 @@
|
|||||||
|
Release 0.27.1
|
||||||
|
==============
|
||||||
|
|
||||||
|
This releaes fixes CVE-2018-6360.
|
||||||
|
|
||||||
|
Fixes and Minor Enhancements
|
||||||
|
----------------------------
|
||||||
|
- ytdl_hook: whitelist protocols from urls retrieved from youtube-dl (#5456)
|
||||||
|
|
||||||
Release 0.27.0
|
Release 0.27.0
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,18 @@ local ytdl = {
|
|||||||
|
|
||||||
local chapter_list = {}
|
local chapter_list = {}
|
||||||
|
|
||||||
|
function Set (t)
|
||||||
|
local set = {}
|
||||||
|
for _, v in pairs(t) do set[v] = true end
|
||||||
|
return set
|
||||||
|
end
|
||||||
|
|
||||||
|
local safe_protos = Set {
|
||||||
|
"http", "https", "ftp", "ftps",
|
||||||
|
"rtmp", "rtmps", "rtmpe", "rtmpt", "rtmpts", "rtmpte",
|
||||||
|
"data"
|
||||||
|
}
|
||||||
|
|
||||||
local function exec(args)
|
local function exec(args)
|
||||||
local ret = utils.subprocess({args = args})
|
local ret = utils.subprocess({args = args})
|
||||||
return ret.status, ret.stdout, ret
|
return ret.status, ret.stdout, ret
|
||||||
@@ -71,6 +83,15 @@ local function edl_escape(url)
|
|||||||
return "%" .. string.len(url) .. "%" .. url
|
return "%" .. string.len(url) .. "%" .. url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function url_is_safe(url)
|
||||||
|
local proto = type(url) == "string" and url:match("^(.+)://") or nil
|
||||||
|
local safe = proto and safe_protos[proto]
|
||||||
|
if not safe then
|
||||||
|
msg.error(("Ignoring potentially unsafe url: '%s'"):format(url))
|
||||||
|
end
|
||||||
|
return safe
|
||||||
|
end
|
||||||
|
|
||||||
local function time_to_secs(time_string)
|
local function time_to_secs(time_string)
|
||||||
local ret
|
local ret
|
||||||
|
|
||||||
@@ -182,6 +203,9 @@ local function edl_track_joined(fragments, protocol, is_live, base)
|
|||||||
|
|
||||||
for i = offset, #fragments do
|
for i = offset, #fragments do
|
||||||
local fragment = fragments[i]
|
local fragment = fragments[i]
|
||||||
|
if not url_is_safe(join_url(base, fragment)) then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
table.insert(parts, edl_escape(join_url(base, fragment)))
|
table.insert(parts, edl_escape(join_url(base, fragment)))
|
||||||
if fragment.duration then
|
if fragment.duration then
|
||||||
parts[#parts] =
|
parts[#parts] =
|
||||||
@@ -201,6 +225,9 @@ local function add_single_video(json)
|
|||||||
edl_track = edl_track_joined(track.fragments,
|
edl_track = edl_track_joined(track.fragments,
|
||||||
track.protocol, json.is_live,
|
track.protocol, json.is_live,
|
||||||
track.fragment_base_url)
|
track.fragment_base_url)
|
||||||
|
if not edl_track and not url_is_safe(track.url) then
|
||||||
|
return
|
||||||
|
end
|
||||||
if track.acodec and track.acodec ~= "none" then
|
if track.acodec and track.acodec ~= "none" then
|
||||||
-- audio track
|
-- audio track
|
||||||
mp.commandv("audio-add",
|
mp.commandv("audio-add",
|
||||||
@@ -217,6 +244,9 @@ local function add_single_video(json)
|
|||||||
edl_track = edl_track_joined(json.fragments, json.protocol,
|
edl_track = edl_track_joined(json.fragments, json.protocol,
|
||||||
json.is_live, json.fragment_base_url)
|
json.is_live, json.fragment_base_url)
|
||||||
|
|
||||||
|
if not edl_track and not url_is_safe(json.url) then
|
||||||
|
return
|
||||||
|
end
|
||||||
-- normal video or single track
|
-- normal video or single track
|
||||||
streamurl = edl_track or json.url
|
streamurl = edl_track or json.url
|
||||||
set_http_headers(json.http_headers)
|
set_http_headers(json.http_headers)
|
||||||
@@ -408,6 +438,10 @@ mp.add_hook("on_load", 10, function ()
|
|||||||
|
|
||||||
msg.debug("EDL: " .. playlist)
|
msg.debug("EDL: " .. playlist)
|
||||||
|
|
||||||
|
if not playlist then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- can't change the http headers for each entry, so use the 1st
|
-- can't change the http headers for each entry, so use the 1st
|
||||||
if json.entries[1] then
|
if json.entries[1] then
|
||||||
set_http_headers(json.entries[1].http_headers)
|
set_http_headers(json.entries[1].http_headers)
|
||||||
@@ -455,14 +489,14 @@ mp.add_hook("on_load", 10, function ()
|
|||||||
add_single_video(json.entries[1])
|
add_single_video(json.entries[1])
|
||||||
else
|
else
|
||||||
|
|
||||||
local playlist = "#EXTM3U\n"
|
local playlist = {"#EXTM3U"}
|
||||||
for i, entry in pairs(json.entries) do
|
for i, entry in pairs(json.entries) do
|
||||||
local site = entry.url
|
local site = entry.url
|
||||||
local title = entry.title
|
local title = entry.title
|
||||||
|
|
||||||
if not (title == nil) then
|
if not (title == nil) then
|
||||||
title = string.gsub(title, '%s+', ' ')
|
title = string.gsub(title, '%s+', ' ')
|
||||||
playlist = playlist .. "#EXTINF:0," .. title .. "\n"
|
table.insert(playlist, "#EXTINF:0," .. title)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- some extractors will still return the full info for
|
-- some extractors will still return the full info for
|
||||||
@@ -475,10 +509,17 @@ mp.add_hook("on_load", 10, function ()
|
|||||||
site = entry["webpage_url"]
|
site = entry["webpage_url"]
|
||||||
end
|
end
|
||||||
|
|
||||||
playlist = playlist .. "ytdl://" .. site .. "\n"
|
-- links with only youtube id as returned by --flat-playlist
|
||||||
|
if not site:find("://") then
|
||||||
|
table.insert(playlist, "ytdl://" .. site)
|
||||||
|
elseif url_is_safe(site) then
|
||||||
|
table.insert(playlist, site)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mp.set_property("stream-open-filename", "memory://" .. playlist)
|
if #playlist > 0 then
|
||||||
|
mp.set_property("stream-open-filename", "memory://" .. table.concat(playlist, "\n"))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
else -- probably a video
|
else -- probably a video
|
||||||
|
|||||||
Reference in new issue
Block a user