Make it so a user cannot upload anything but zip

TODO add better feedback than "error"
This commit is contained in:
Andrew 2022-09-27 23:07:44 -04:00
parent f090bf8c6f
commit a21bb36f7c
2 changed files with 5 additions and 2 deletions

View File

@ -673,9 +673,9 @@ class TasksManager:
user.id, {"pfp": self.helper.get_gravatar_image(user.email)}
)
# Search for old files in imports
for file in os.listdir(os.path.join(self.controller.project_root), "imports"):
for file in os.listdir(os.path.join(self.controller.project_root, "imports")):
if self.helper.is_file_older_than_x_days(
os.path.join(self.controller.project_root), "imports", file
os.path.join(self.controller.project_root, "imports", file)
):
try:
os.remove(os.path.join(file))

View File

@ -109,6 +109,9 @@ class UploadHandler(BaseHandler):
self.helper.ensure_dir_exists(path)
filename = self.request.headers.get("X-FileName", None)
if not str(filename).endswith(".zip"):
self.helper.websocket_helper.broadcast("close_upload_box", "error")
self.finish("error")
full_path = os.path.join(path, filename)
if self.do_upload: