mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-26 16:52:12 +05:30
Fix local redirects in /videoplayback
This commit is contained in:
parent
665ef9424e
commit
61769c6f9c
@ -4200,6 +4200,11 @@ get "/videoplayback" do |env|
|
||||
fvip = query_params["fvip"]? || "3"
|
||||
mns = query_params["mn"].split(",")
|
||||
|
||||
if query_params["region"]?
|
||||
region = query_params["region"]
|
||||
query_params.delete("region")
|
||||
end
|
||||
|
||||
if query_params["host"]? && !query_params["host"].empty?
|
||||
host = "https://#{query_params["host"]}"
|
||||
query_params.delete("host")
|
||||
@ -4216,8 +4221,6 @@ get "/videoplayback" do |env|
|
||||
end
|
||||
end
|
||||
|
||||
region = query_params["region"]?
|
||||
|
||||
response = HTTP::Client::Response.new(403)
|
||||
5.times do
|
||||
begin
|
||||
@ -4240,6 +4243,8 @@ get "/videoplayback" do |env|
|
||||
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||
|
||||
url = url.full_path
|
||||
url += "&host=#{host.lchop("https://")}"
|
||||
|
||||
if region
|
||||
url += "®ion=#{region}"
|
||||
end
|
||||
@ -4260,6 +4265,20 @@ get "/videoplayback" do |env|
|
||||
env.response.headers[key] = value
|
||||
end
|
||||
|
||||
if response.headers["Location"]?
|
||||
url = URI.parse(response.headers["Location"])
|
||||
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||
|
||||
url = url.full_path
|
||||
url += "&host=#{host.lchop("https://")}"
|
||||
|
||||
if region
|
||||
url += "®ion=#{region}"
|
||||
end
|
||||
|
||||
next env.redirect url
|
||||
end
|
||||
|
||||
if title = query_params["title"]?
|
||||
# https://blog.fastmail.com/2011/06/24/download-non-english-filenames/
|
||||
env.response.headers["Content-Disposition"] = "attachment; filename=\"#{URI.escape(title)}\"; filename*=UTF-8''#{URI.escape(title)}"
|
||||
|
Loading…
Reference in New Issue
Block a user