From 515afb52edaa1ebfa87acb158c0634b009f15b8a Mon Sep 17 00:00:00 2001 From: IM Date: Fri, 3 May 2024 23:07:04 +0300 Subject: [PATCH] move check predefined_collections props to config.py --- radicale/app/__init__.py | 4 +--- radicale/config.py | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/radicale/app/__init__.py b/radicale/app/__init__.py index 40809e2d..72b4b2b1 100644 --- a/radicale/app/__init__.py +++ b/radicale/app/__init__.py @@ -48,7 +48,6 @@ from radicale.app.propfind import ApplicationPartPropfind from radicale.app.proppatch import ApplicationPartProppatch from radicale.app.put import ApplicationPartPut from radicale.app.report import ApplicationPartReport -from radicale.item import check_and_sanitize_props from radicale.log import logger # Combination of types.WSGIStartResponse and WSGI application return value @@ -274,8 +273,7 @@ class Application(ApplicationPartDelete, ApplicationPartHead, jsn_coll = self.configuration.get("storage", "predefined_collections") for (name_coll, props) in jsn_coll.items(): try: - checked_props = check_and_sanitize_props(props) - self._storage.create_collection(principal_path + name_coll, props=checked_props) + self._storage.create_collection(principal_path + name_coll, props=props) except ValueError as e: logger.warning("Failed to create predefined collection %r: %s", name_coll, e) except ValueError as e: diff --git a/radicale/config.py b/radicale/config.py index d2e66835..f21a9980 100644 --- a/radicale/config.py +++ b/radicale/config.py @@ -37,6 +37,7 @@ from typing import (Any, Callable, ClassVar, Iterable, List, Optional, Sequence, Tuple, TypeVar, Union) from radicale import auth, hook, rights, storage, types, web +from radicale.item import check_and_sanitize_props DEFAULT_CONFIG_PATH: str = os.pathsep.join([ "?/etc/radicale/config", @@ -105,7 +106,11 @@ def _convert_to_bool(value: Any) -> bool: def json_str(value: Any) -> dict: if not value: return {} - return json.loads(value) + ret = json.loads(value) + for (name_coll, props) in ret.items(): + checked_props = check_and_sanitize_props(props) + ret[name_coll] = checked_props + return ret INTERNAL_OPTIONS: Sequence[str] = ("_allow_extra",)