Changeset - 3705a2ba1dac
[Not reviewed]
0 1 0
Brett Smith (brett) - 5 years ago 2016-11-03 14:58:23
brett@sfconservancy.org
static: Re-fix path manipulation in index.

* Strip any leading / to treat it as a relative path.
* Append `index.html` before converting to bytes.
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
www/conservancy/static/views.py
Show inline comments
...
 
@@ -36,14 +36,14 @@ def fundgoal_lookup(fundraiser_sought):
 
        return None
 

	
 
def index(request, *args, **kwargs):
 
    path = request.path
 
    path = request.path.lstrip(u'/')
 
    if path.endswith(u'/'):
 
        path += u'index.html'
 
    try:
 
        path_bytes = path.encode(FILESYSTEM_ENCODING)
 
    except UnicodeEncodeError:
 
        # If the path can't be expressed on the filesystem, it must not exist.
 
        return handler404(request)
 
    if path.endswith(u'/'):
 
        path += u'index.html'
 
    fullpath = os.path.join(STATIC_ROOT, path_bytes)
 
    if not os.path.exists(fullpath):
 
        return handler404(request)
0 comments (0 inline, 0 general)