From cf15b41f3d3b2d63586e94a8768e28ad40d3f1e4 Mon Sep 17 00:00:00 2001 From: yotamolenik Date: Sun, 16 Nov 2025 13:33:22 +0200 Subject: [PATCH] unback: replace illegal characters in path names --- pyiosbackup/backup.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pyiosbackup/backup.py b/pyiosbackup/backup.py index eb0ca89..eb17355 100644 --- a/pyiosbackup/backup.py +++ b/pyiosbackup/backup.py @@ -18,6 +18,13 @@ logger = logging.getLogger('pyiosbackup') logger.addHandler(logging.NullHandler()) +ILLEGAL_CHARACTERS_IN_PATH = ['<', '>', ':', '"', '|' , '?', '*'] + +def replace_illegal_characters(path: str) -> str: + for char in ILLEGAL_CHARACTERS_IN_PATH: + path = path.replace(char, '~') + return path + class Backup: def __init__(self, backup_path: Path, manifest_db: ManifestDb, manifest_plist: ManifestPlist, status, info, @@ -107,6 +114,7 @@ def unback(self, path='.'): dest_dir = Path(path) dest_dir.mkdir(exist_ok=True, parents=True) for file in self.iter_files(): + file.relative_path = replace_illegal_characters(file.relative_path) dest_file = dest_dir / file.domain / file.relative_path logger.debug(f'Extracting file {file.filename} to {dest_file}') dest_file.parent.mkdir(exist_ok=True, parents=True)