Move invalid path test upper level

This commit is contained in:
shortcutme 2017-02-27 11:21:22 +01:00
parent a72c4eafff
commit 871588aa9f
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -346,6 +346,9 @@ class UiRequest(object):
# Serve a media for site
def actionSiteMedia(self, path, header_length=True):
if ".." in path: # File not in allowed path
return self.error403("Invalid file path")
path_parts = self.parsePath(path)
# Check wrapper nonce
@ -365,9 +368,6 @@ class UiRequest(object):
if path_parts: # Looks like a valid path
address = path_parts["address"]
file_path = "%s/%s/%s" % (config.data_dir, address, path_parts["inner_path"])
if ".." in path_parts["inner_path"]: # File not in allowed path
return self.error403("Invalid file path")
else:
if config.debug and file_path.split("/")[-1].startswith("all."):
# If debugging merge *.css to all.css and *.js to all.js
site = self.server.sites.get(address)