static: Re-fix path manipulation in index.
* Strip any leading / to treat it as a relative path. * Append `index.html` before converting to bytes.
This commit is contained in:
parent
93787dc820
commit
3705a2ba1d
1 changed files with 3 additions and 3 deletions
|
@ -36,14 +36,14 @@ def fundgoal_lookup(fundraiser_sought):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def index(request, *args, **kwargs):
|
def index(request, *args, **kwargs):
|
||||||
path = request.path
|
path = request.path.lstrip(u'/')
|
||||||
|
if path.endswith(u'/'):
|
||||||
|
path += u'index.html'
|
||||||
try:
|
try:
|
||||||
path_bytes = path.encode(FILESYSTEM_ENCODING)
|
path_bytes = path.encode(FILESYSTEM_ENCODING)
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
# If the path can't be expressed on the filesystem, it must not exist.
|
# If the path can't be expressed on the filesystem, it must not exist.
|
||||||
return handler404(request)
|
return handler404(request)
|
||||||
if path.endswith(u'/'):
|
|
||||||
path += u'index.html'
|
|
||||||
fullpath = os.path.join(STATIC_ROOT, path_bytes)
|
fullpath = os.path.join(STATIC_ROOT, path_bytes)
|
||||||
if not os.path.exists(fullpath):
|
if not os.path.exists(fullpath):
|
||||||
return handler404(request)
|
return handler404(request)
|
||||||
|
|
Loading…
Reference in a new issue