From 7ff616330929b0f2ee6d385d7e798d78261afc5e Mon Sep 17 00:00:00 2001 From: fengkx Date: Sat, 4 Jan 2020 12:56:12 +0800 Subject: [PATCH] fix: fix import uploads (#1173) * Fixes issue with importing backups that contain invalid empty directories --- CTFd/utils/exports/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CTFd/utils/exports/__init__.py b/CTFd/utils/exports/__init__.py index 7ece956..62f14c3 100644 --- a/CTFd/utils/exports/__init__.py +++ b/CTFd/utils/exports/__init__.py @@ -304,7 +304,7 @@ def import_ctf(backup, erase=True): for f in files: filename = f.split(os.sep, 1) - if len(filename) < 2: # just an empty uploads directory (e.g. uploads/) + if len(filename) < 2 or os.path.basename(filename[1]) == '': # just an empty uploads directory (e.g. uploads/) or any directory continue filename = filename[1] # Get the second entry in the list (the actual filename)