mirror of
				https://github.com/iv-org/invidious.git
				synced 2025-11-03 22:21:55 +00:00 
			
		
		
		
	video_playback: Check "host" parameter validity
This commit is contained in:
		@@ -14,12 +14,18 @@ module Invidious::Routes::VideoPlayback
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if query_params["host"]? && !query_params["host"].empty?
 | 
					    if query_params["host"]? && !query_params["host"].empty?
 | 
				
			||||||
      host = "https://#{query_params["host"]}"
 | 
					      host = query_params["host"]
 | 
				
			||||||
      query_params.delete("host")
 | 
					      query_params.delete("host")
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      host = "https://r#{fvip}---#{mns.pop}.googlevideo.com"
 | 
					      host = "r#{fvip}---#{mns.pop}.googlevideo.com"
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Sanity check, to avoid being used as an open proxy
 | 
				
			||||||
 | 
					    if !host.matches?(/[\w-]+.googlevideo.com/)
 | 
				
			||||||
 | 
					      return error_template(400, "Invalid \"host\" parameter.")
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    host = "https://#{host}"
 | 
				
			||||||
    url = "/videoplayback?#{query_params}"
 | 
					    url = "/videoplayback?#{query_params}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    headers = HTTP::Headers.new
 | 
					    headers = HTTP::Headers.new
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user