httpserver: Fix incorrect path joining

This commit is contained in:
Valentin Lorentz 2023-10-17 18:59:46 +02:00
parent e7824213ae
commit edb13f65df
2 changed files with 2 additions and 2 deletions

View File

@ -941,7 +941,7 @@ class Directory(registry.String):
if os.path.isabs(filename):
filename = os.path.abspath(filename)
selfAbs = os.path.abspath(myself)
commonPrefix = os.path.commonprefix([selfAbs, filename])
commonPrefix = os.path.commonpath([selfAbs, filename])
filename = filename[len(commonPrefix):]
elif not os.path.isabs(myself):
if filename.startswith(myself):

View File

@ -337,7 +337,7 @@ class Static(SupyHTTPServerCallback):
super(Static, self).__init__()
self._mimetype = mimetype
def doGetOrHead(self, handler, path, write_content):
response = get_template(path)
response = get_template(path[1:]) # strip leading /
if minisix.PY3:
response = response.encode()
handler.send_response(200)