Skip to content

Commit

Permalink
fix: Use a whitelist for path characters instead of disallowing only …
Browse files Browse the repository at this point in the history
…whitespace
  • Loading branch information
FHeilmann committed Dec 27, 2023
1 parent 5c80b34 commit f5e156f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions voron_toolkit/tools/file_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f5e156f

Please sign in to comment.