From d3018a4c06fe1ac4de5a135f61054113359f65e3 Mon Sep 17 00:00:00 2001 From: Francois Lesueur Date: Fri, 27 Feb 2026 15:04:00 +0100 Subject: [PATCH 1/4] improve path_to_filesystem() performance --- radicale/pathutils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/radicale/pathutils.py b/radicale/pathutils.py index 488dbfc0..1be03232 100644 --- a/radicale/pathutils.py +++ b/radicale/pathutils.py @@ -286,10 +286,9 @@ def path_to_filesystem(root: str, sane_path: str) -> str: safe_path = os.path.join(safe_path, part) # Check for conflicting files (e.g. case-insensitive file systems # or short names on Windows file systems) - if os.path.lexists(safe_path): - with os.scandir(safe_path_parent) as entries: - if part not in (e.name for e in entries): - raise CollidingPathError(part) + if (os.path.lexists(safe_path) and + not os.path.realpath(safe_path).endswith(part)): + raise CollidingPathError(part) return safe_path From 8121ec0a849bb82bd24b5fc42896ae95bf98a5e7 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sun, 1 Mar 2026 08:54:32 +0100 Subject: [PATCH 2/4] Fix indentation for raising CollidingPathError --- radicale/pathutils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radicale/pathutils.py b/radicale/pathutils.py index 1be03232..fc6504b8 100644 --- a/radicale/pathutils.py +++ b/radicale/pathutils.py @@ -287,8 +287,8 @@ def path_to_filesystem(root: str, sane_path: str) -> str: # Check for conflicting files (e.g. case-insensitive file systems # or short names on Windows file systems) if (os.path.lexists(safe_path) and - not os.path.realpath(safe_path).endswith(part)): - raise CollidingPathError(part) + not os.path.realpath(safe_path).endswith(part)): + raise CollidingPathError(part) return safe_path From 770cb31e7a719fb6dc78d9bf0b1b39f806c3fe77 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sun, 1 Mar 2026 08:56:38 +0100 Subject: [PATCH 3/4] Remove unused variable safe_path_parent Remove unused variable safe_path_parent --- radicale/pathutils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/radicale/pathutils.py b/radicale/pathutils.py index fc6504b8..cdbebd6c 100644 --- a/radicale/pathutils.py +++ b/radicale/pathutils.py @@ -282,7 +282,6 @@ def path_to_filesystem(root: str, sane_path: str) -> str: for part in parts: if not is_safe_filesystem_path_component(part): raise UnsafePathError(part) - safe_path_parent = safe_path safe_path = os.path.join(safe_path, part) # Check for conflicting files (e.g. case-insensitive file systems # or short names on Windows file systems) From 0be7b620c957f84b7ab9f3afbadbcfda7d7faf11 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sun, 1 Mar 2026 09:00:16 +0100 Subject: [PATCH 4/4] Improve path collision check formatting Refactor path collision check for readability. --- radicale/pathutils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/radicale/pathutils.py b/radicale/pathutils.py index cdbebd6c..b1ddce00 100644 --- a/radicale/pathutils.py +++ b/radicale/pathutils.py @@ -285,9 +285,8 @@ def path_to_filesystem(root: str, sane_path: str) -> str: safe_path = os.path.join(safe_path, part) # Check for conflicting files (e.g. case-insensitive file systems # or short names on Windows file systems) - if (os.path.lexists(safe_path) and - not os.path.realpath(safe_path).endswith(part)): - raise CollidingPathError(part) + if (os.path.lexists(safe_path) and not os.path.realpath(safe_path).endswith(part)): + raise CollidingPathError(part) return safe_path