diff --git a/www/conservancy/static/views.py b/www/conservancy/static/views.py index 8029241dbcf5cb3e16b0c5fe19ceb72c75f1ee28..ea0a6bdd8f46ba001057fdf93e8d55775550aa7e 100644 --- a/www/conservancy/static/views.py +++ b/www/conservancy/static/views.py @@ -34,7 +34,12 @@ def index(request, *args, **kwargs): if path.endswith(u'/'): path += u'index.html' fullpath = os.path.join(STATIC_ROOT, path) - if not os.path.exists(fullpath): + try: + # Junk URLs in production (Python 3.5) are causing UnicodeEncodeErrors + # here. Can't reproduce in development in Python 3.9 - only Python 2.7. + if not os.path.exists(fullpath): + return handler404(request) + except UnicodeEncodeError: return handler404(request) content_type, _ = mimetypes.guess_type(path) if content_type != 'text/html':