From ef497b8fdd0705d1cd889a14d51b2c7f4e2830a6 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Fri, 5 Jun 2026 10:26:20 +0000 Subject: [PATCH] Add comments about PurePath usage --- src/openflexure_microscope_server/utilities.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/openflexure_microscope_server/utilities.py b/src/openflexure_microscope_server/utilities.py index 558fac66..d468ac80 100644 --- a/src/openflexure_microscope_server/utilities.py +++ b/src/openflexure_microscope_server/utilities.py @@ -166,6 +166,9 @@ def _path_normalised(unsafe_path_string: str) -> bool: def _no_trailing_dots_or_whitespaces(unsafe_path_string: str) -> bool: """Disallow trailing dots or whitespace.""" + # Use PurePath from Python's standard library to iterate over each element + # in the path as separated by path separators. For example: + # "foo/bar/tada.py" -> ("foo", "bar", "tada.py") for component in PurePath(unsafe_path_string).parts: if component == "..": continue