diff --git a/radicale/app/__init__.py b/radicale/app/__init__.py index 64685090..96a441ef 100644 --- a/radicale/app/__init__.py +++ b/radicale/app/__init__.py @@ -168,18 +168,6 @@ class Application(ApplicationPartDelete, ApplicationPartHead, self._validate_user_value = "no-unicode" if self._validate_path_value not in ["strict", "no-unicode"]: self._validate_path_value = "no-unicode" - if not self._storage._supports_problematic_chars or not self._storage._supports_trailing_whitespace: - if self._validate_user_value not in ["strict"]: - self._validate_user_value = "strict" - if self._validate_path_value not in ["strict"]: - self._validate_path_value = "strict" - logger.notice("validate user value: %r (enforced by limited support of collection storage)", self._validate_user_value) - logger.notice("validate path value: %r (enforced by limited support of collection storage)", self._validate_path_value) - elif not self._storage._supports_problematic_chars or not self._storage._supports_trailing_whitespace: - if self._validate_user_value not in ["strict"]: - self._validate_user_value = "strict" - if self._validate_path_value not in ["strict"]: - self._validate_path_value = "strict" logger.notice("validate user value: %r (enforced by limited support of collection storage)", self._validate_user_value) logger.notice("validate path value: %r (enforced by limited support of collection storage)", self._validate_path_value) else: diff --git a/radicale/app/base.py b/radicale/app/base.py index 81bc6258..fd4d9342 100644 --- a/radicale/app/base.py +++ b/radicale/app/base.py @@ -127,6 +127,8 @@ class ApplicationBase: check_unicode_letter = (validation_type == "unicode-letter") check_no_unicode = (validation_type == "no-unicode") logger.trace("_check_format investigate %r (validation_type=%r check_minimal=%s check_unicode_letter=%s check_no_unicode=%s)", string, validation_type, check_minimal, check_unicode_letter, check_no_unicode) + if not self._storage._supports_trailing_whitespace and string.endswith(' '): + return False for c in string: if c <= chr(31) or (c >= chr(127) and c <= chr(159)): # ASCII: control char @@ -135,15 +137,15 @@ class ApplicationBase: # https://unicodeplus.com/category # Unicode: control return False - if check_minimal: + if check_minimal or not self._storage._supports_problematic_chars: if c in blacklist_minimal: logger.trace("_check_format found %r", c) return False - elif check_unicode_letter: + if check_unicode_letter: if c not in whitelist_unicode: if unicodedata.category(c)[0] != "L": return False - elif check_no_unicode: + if check_no_unicode: if ord(c) > 255: return False return True diff --git a/radicale/tests/test_auth.py b/radicale/tests/test_auth.py index 1ef34cdc..d2f71cfe 100644 --- a/radicale/tests/test_auth.py +++ b/radicale/tests/test_auth.py @@ -335,7 +335,7 @@ class TestBaseAuthRequests(BaseTest): def test_htpasswd_whitespace_user(self) -> None: for user in (" tmp", "tmp ", " tmp "): - if not pathutils.path_supports_trailing_whitespace(self.colpath) and (user.endswith(' ') or user.startswith(' ')): + if not pathutils.path_supports_trailing_whitespace(self.colpath) and user.endswith(' '): check = 401 else: check = 207