From f5e156ff102be1001d1b1aeb756d2623c05a3aaf Mon Sep 17 00:00:00 2001 From: Florian Heilmann Date: Wed, 27 Dec 2023 15:26:41 +0100 Subject: [PATCH] fix: Use a whitelist for path characters instead of disallowing only whitespace --- voron_toolkit/tools/file_checker.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/voron_toolkit/tools/file_checker.py b/voron_toolkit/tools/file_checker.py index e955e5a..fe6d417 100644 --- a/voron_toolkit/tools/file_checker.py +++ b/voron_toolkit/tools/file_checker.py @@ -33,14 +33,16 @@ def __init__(self: Self, args: configargparse.Namespace) -> None: def _check_for_whitespace(self: Self) -> None: for input_file in self.input_file_list: relative_file_path: str = input_file.relative_to(self.input_dir).as_posix() - result_ok: bool = all(c not in string.whitespace for c in relative_file_path) + result_ok: bool = all(c in string.ascii_letters + string.digits + r"/\[]()_-." for c in relative_file_path) if result_ok: logger.success("File '{}' OK!", input_file) self.result_items[ExtendedResultEnum.SUCCESS].append(ItemResult(item=relative_file_path, extra_info=[""])) else: - logger.error("File '{}' contains whitespace!", relative_file_path) - self.result_items[ExtendedResultEnum.FAILURE].append(ItemResult(item=relative_file_path, extra_info=["This file contains whitespace!"])) + logger.error("File-path '{}' contains illegal characters!", relative_file_path) + self.result_items[ExtendedResultEnum.FAILURE].append( + ItemResult(item=relative_file_path, extra_info=["This file-path contains illegal characters!"]) + ) self.return_status = ExtendedResultEnum.FAILURE def _check_for_license_files(self: Self) -> None: