From 574cb2dae8534a8abba5710217e4f6c8655ff854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Sat, 19 Dec 2020 22:24:32 -0500 Subject: Fix env["PATH_INFO"] for UWSGI, prevents bad url formatting e.g: ValueError: Invalid or unsupported url: https:/www.youtube.com/watch --- server.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server.py b/server.py index 9e4f674..fc9d30e 100644 --- a/server.py +++ b/server.py @@ -195,6 +195,12 @@ def site_dispatch(env, start_response): # correct malformed query string with ? separators instead of & env['QUERY_STRING'] = env['QUERY_STRING'].replace('?', '&') + # Fix PATH_INFO for UWSGI + if 'REQUEST_URI' in env: + env['PATH_INFO'] = urllib.parse.unquote( + env['REQUEST_URI'].split('?')[0] + ) + method = env['REQUEST_METHOD'] path = env['PATH_INFO'] -- cgit v1.2.3