Skip to content

Commit

Permalink
fix(backups): skip pontentially bogus files in backups
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Jun 28, 2024
1 parent 0137a35 commit b6a7eac
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions weblate/trans/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,11 @@ def restore(self, project_name: str, project_slug: str, user, billing=None):
# Extract VCS
for name in zipfile.namelist():
if name.startswith(self.VCS_PREFIX):
targetpath = os.path.join(
project.full_path, name[self.VCS_PREFIX_LEN :]
)
path = name[self.VCS_PREFIX_LEN :]
# Skip potentially dangerous paths
if path != os.path.normpath(path):
continue
targetpath = os.path.join(project.full_path, path)
upperdirs = os.path.dirname(targetpath)
if upperdirs and not os.path.exists(upperdirs):
os.makedirs(upperdirs)
Expand Down

0 comments on commit b6a7eac

Please # to comment.