From cbdc404703f5895d04e6d6af4241921b2a7bc39c Mon Sep 17 00:00:00 2001 From: James Taylor Date: Thu, 20 Dec 2018 01:25:36 -0800 Subject: Correctly handle case where video ID is too short --- youtube/youtube.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'youtube/youtube.py') diff --git a/youtube/youtube.py b/youtube/youtube.py index cb35eac..eb319e1 100644 --- a/youtube/youtube.py +++ b/youtube/youtube.py @@ -26,6 +26,10 @@ def youtube(env, start_response): return comments.get_comments_page(query_string).encode() elif path == "/watch": + video_id = urllib.parse.parse_qs(query_string)['v'][0] + if len(video_id) < 11: + start_response('404 Not Found', ()) + return b'Incomplete video id (too short): ' + video_id.encode('ascii') start_response('200 OK', (('Content-type','text/html'),) ) return watch.get_watch_page(query_string).encode() -- cgit v1.2.3