mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-09 15:02:14 +05:30
encode parameters retrieved from url
This commit is contained in:
parent
99f524b73e
commit
2a012f86da
@ -394,7 +394,7 @@ module Invidious::Routes::API::V1::Channels
|
|||||||
locale = env.get("preferences").as(Preferences).locale
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
|
|
||||||
env.response.content_type = "application/json"
|
env.response.content_type = "application/json"
|
||||||
id = env.params.url["id"].to_s
|
id = URI.encode_www_form(env.params.url["id"].to_s)
|
||||||
ucid = env.params.query["ucid"]?
|
ucid = env.params.query["ucid"]?
|
||||||
|
|
||||||
thin_mode = env.params.query["thin_mode"]?
|
thin_mode = env.params.query["thin_mode"]?
|
||||||
@ -406,9 +406,9 @@ module Invidious::Routes::API::V1::Channels
|
|||||||
if ucid.nil?
|
if ucid.nil?
|
||||||
response = YoutubeAPI.resolve_url("https://www.youtube.com/post/#{id}")
|
response = YoutubeAPI.resolve_url("https://www.youtube.com/post/#{id}")
|
||||||
return error_json(400, "Invalid post ID") if response["error"]?
|
return error_json(400, "Invalid post ID") if response["error"]?
|
||||||
ucid = response.dig("endpoint", "browseEndpoint", "browseId").as_s
|
ucid = URI.encode_www_form(response.dig("endpoint", "browseEndpoint", "browseId").as_s)
|
||||||
else
|
else
|
||||||
ucid = ucid.to_s
|
ucid = URI.encode_www_form(ucid.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -423,7 +423,7 @@ module Invidious::Routes::API::V1::Channels
|
|||||||
|
|
||||||
env.response.content_type = "application/json"
|
env.response.content_type = "application/json"
|
||||||
|
|
||||||
id = env.params.url["id"]
|
id = URI.encode_www_form(env.params.url["id"])
|
||||||
|
|
||||||
thin_mode = env.params.query["thin_mode"]?
|
thin_mode = env.params.query["thin_mode"]?
|
||||||
thin_mode = thin_mode == "true"
|
thin_mode = thin_mode == "true"
|
||||||
@ -437,9 +437,9 @@ module Invidious::Routes::API::V1::Channels
|
|||||||
if ucid.nil?
|
if ucid.nil?
|
||||||
response = YoutubeAPI.resolve_url("https://www.youtube.com/post/#{id}")
|
response = YoutubeAPI.resolve_url("https://www.youtube.com/post/#{id}")
|
||||||
return error_json(400, "Invalid post ID") if response["error"]?
|
return error_json(400, "Invalid post ID") if response["error"]?
|
||||||
ucid = response.dig("endpoint", "browseEndpoint", "browseId").as_s
|
ucid = URI.encode_www_form(response.dig("endpoint", "browseEndpoint", "browseId").as_s)
|
||||||
else
|
else
|
||||||
ucid = ucid.to_s
|
ucid = URI.encode_www_form(ucid.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
case continuation
|
case continuation
|
||||||
|
@ -392,7 +392,7 @@ module Invidious::Routes::API::V1::Videos
|
|||||||
|
|
||||||
env.response.content_type = "application/json"
|
env.response.content_type = "application/json"
|
||||||
|
|
||||||
clip_id = env.params.url["id"]
|
clip_id = URI.encode_www_form(env.params.url["id"])
|
||||||
region = env.params.query["region"]?
|
region = env.params.query["region"]?
|
||||||
proxy = {"1", "true"}.any? &.== env.params.query["local"]?
|
proxy = {"1", "true"}.any? &.== env.params.query["local"]?
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ module Invidious::Routes::Channels
|
|||||||
|
|
||||||
def self.post(env)
|
def self.post(env)
|
||||||
# /post/{postId}
|
# /post/{postId}
|
||||||
id = env.params.url["id"]
|
id = URI.encode_www_form(env.params.url["id"])
|
||||||
ucid = env.params.query["ucid"]?
|
ucid = env.params.query["ucid"]?
|
||||||
|
|
||||||
prefs = env.get("preferences").as(Preferences)
|
prefs = env.get("preferences").as(Preferences)
|
||||||
@ -253,14 +253,14 @@ module Invidious::Routes::Channels
|
|||||||
nojs = nojs == "1"
|
nojs = nojs == "1"
|
||||||
|
|
||||||
if !ucid.nil?
|
if !ucid.nil?
|
||||||
ucid = ucid.to_s
|
ucid = URI.encode_www_form(ucid.to_s)
|
||||||
post_response = fetch_channel_community_post(ucid, id, locale, "json", thin_mode)
|
post_response = fetch_channel_community_post(ucid, id, locale, "json", thin_mode)
|
||||||
else
|
else
|
||||||
# resolve the url to get the author's UCID
|
# resolve the url to get the author's UCID
|
||||||
response = YoutubeAPI.resolve_url("https://www.youtube.com/post/#{id}")
|
response = YoutubeAPI.resolve_url("https://www.youtube.com/post/#{id}")
|
||||||
return error_template(400, "Invalid post ID") if response["error"]?
|
return error_template(400, "Invalid post ID") if response["error"]?
|
||||||
|
|
||||||
ucid = response.dig("endpoint", "browseEndpoint", "browseId").as_s
|
ucid = URI.encode_www_form(response.dig("endpoint", "browseEndpoint", "browseId").as_s)
|
||||||
post_response = fetch_channel_community_post(ucid, id, locale, "json", thin_mode)
|
post_response = fetch_channel_community_post(ucid, id, locale, "json", thin_mode)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ module Invidious::Routes::Watch
|
|||||||
locale = env.get("preferences").as(Preferences).locale
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
region = env.params.query["region"]?
|
region = env.params.query["region"]?
|
||||||
|
|
||||||
id = env.params.query["id"]
|
id = URI.encode_www_form(env.params.query["id"])
|
||||||
continuation = env.params.query["continuation"]?
|
continuation = env.params.query["continuation"]?
|
||||||
|
|
||||||
source = env.params.query["source"]? || "youtube"
|
source = env.params.query["source"]? || "youtube"
|
||||||
@ -356,9 +356,9 @@ module Invidious::Routes::Watch
|
|||||||
if ucid.nil?
|
if ucid.nil?
|
||||||
response = YoutubeAPI.resolve_url("https://www.youtube.com/post/#{id}")
|
response = YoutubeAPI.resolve_url("https://www.youtube.com/post/#{id}")
|
||||||
return error_json(400, "Invalid post ID") if response["error"]?
|
return error_json(400, "Invalid post ID") if response["error"]?
|
||||||
ucid = response.dig("endpoint", "browseEndpoint", "browseId").as_s
|
ucid = URI.encode_www_form(response.dig("endpoint", "browseEndpoint", "browseId").as_s)
|
||||||
else
|
else
|
||||||
ucid = ucid.to_s
|
ucid = URI.encode_www_form(ucid.to_s)
|
||||||
end
|
end
|
||||||
case continuation
|
case continuation
|
||||||
when nil, ""
|
when nil, ""
|
||||||
|
Loading…
Reference in New Issue
Block a user