Changeset - 6b1ed75d7ac9
[Not reviewed]
0 1 0
Ben Sturmfels (bsturmfels) - 2 years ago 2022-03-14 23:59:47
ben@sturm.com.au
Handle UnicodeEncodeErrors from junk URLs.
1 file changed with 6 insertions and 1 deletions:
0 comments (0 inline, 0 general)
www/conservancy/static/views.py
Show inline comments
...
 
@@ -36,3 +36,8 @@ def index(request, *args, **kwargs):
 
    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)
0 comments (0 inline, 0 general)