diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2022-02-11 05:16:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-11 05:16:47 +0100 |
| commit | ec183e3c9a84dbda976eb1a4e12c791e73f4356a (patch) | |
| tree | e7b694c4bbd089b80a1958977fea41ff42eb7ca8 | |
| parent | 955e3de56d1c5f323bc3b3a2ffc1fe22f52b3088 (diff) | |
| parent | 01135db80a0272b3a6b0bc733b883d90ac414337 (diff) | |
| download | invidious-ec183e3c9a84dbda976eb1a4e12c791e73f4356a.tar.gz invidious-ec183e3c9a84dbda976eb1a4e12c791e73f4356a.tar.bz2 invidious-ec183e3c9a84dbda976eb1a4e12c791e73f4356a.zip | |
Merge pull request #2891 from SamantazFox/check-host-param
video_playback: Check "host" parameter validity
| -rw-r--r-- | src/invidious/routes/video_playback.cr | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/invidious/routes/video_playback.cr b/src/invidious/routes/video_playback.cr index f6340c57..6ac1e780 100644 --- a/src/invidious/routes/video_playback.cr +++ b/src/invidious/routes/video_playback.cr @@ -14,12 +14,18 @@ module Invidious::Routes::VideoPlayback end if query_params["host"]? && !query_params["host"].empty? - host = "https://#{query_params["host"]}" + host = query_params["host"] query_params.delete("host") else - host = "https://r#{fvip}---#{mns.pop}.googlevideo.com" + host = "r#{fvip}---#{mns.pop}.googlevideo.com" 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}" headers = HTTP::Headers.new |
