From d6369588f48e3240dc6c5604732ceceab714d74e Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sun, 31 May 2026 07:26:19 +0200 Subject: [PATCH] sharing/bday/summary: check for not to be empty --- radicale/config.py | 2 +- radicale/sharing/__init__.py | 11 +++++++++-- radicale/tests/test_sharing.py | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/radicale/config.py b/radicale/config.py index a1688305..cf390a2d 100644 --- a/radicale/config.py +++ b/radicale/config.py @@ -597,7 +597,7 @@ DEFAULT_CONFIG_SCHEMA: types.CONFIG_SCHEMA = OrderedDict([ ("conversion_bday_summary_template", { "value": sharing.SHARING_BDAY_SUMMARY_TEMPLATE_DEFAULT, "help": "conversion bday summary template", - "type": sharing.check_template}), + "type": sharing.check_template_not_empty}), ("conversion_bday_description_template", { "value": sharing.SHARING_BDAY_DESCRIPTION_TEMPLATE_DEFAULT, "help": "conversion bday description template", diff --git a/radicale/sharing/__init__.py b/radicale/sharing/__init__.py index 7c5d5339..05a90745 100644 --- a/radicale/sharing/__init__.py +++ b/radicale/sharing/__init__.py @@ -152,6 +152,13 @@ def check_template(data: Any) -> str: return data +def check_template_not_empty(data: Any) -> str: + result = check_template(data) + if result == "": + raise ValueError("template not allowed to be empty") + return data + + def check_template_alarm_trigger(data: Any) -> str: if data is not None and data != '': for entry in data.split('|'): @@ -169,7 +176,7 @@ def check_template_alarm_trigger(data: Any) -> str: if alarm_description is not None and alarm_description != '': try: - check_template(alarm_description) + check_template_not_empty(alarm_description) except Exception as e: raise e else: @@ -179,7 +186,7 @@ def check_template_alarm_trigger(data: Any) -> str: ACTIONS_WHITELIST: dict = { 'config': { - 'conversion_bday_summary_template': check_template, + 'conversion_bday_summary_template': check_template_not_empty, 'conversion_bday_description_template': check_template, 'conversion_bday_alarm_trigger_template': check_template_alarm_trigger, 'conversion_bday_categories': str, diff --git a/radicale/tests/test_sharing.py b/radicale/tests/test_sharing.py index 8d1ee198..24678e64 100644 --- a/radicale/tests/test_sharing.py +++ b/radicale/tests/test_sharing.py @@ -5097,6 +5097,26 @@ permissions: RrWw""") else: raise + logging.info("\n*** configuration test: conversion_bday_summary_template empty") + try: + self.configure({"sharing": { + "conversion_bday_summary_template": "", + }}) + except RuntimeError: + pass + else: + raise + + logging.info("\n*** configuration test: conversion_bday_description_template empty") + try: + self.configure({"sharing": { + "conversion_bday_description_template": "", + }}) + except RuntimeError: + pass + else: + pass + logging.info("\n*** configuration test: conversion_bday_alarm_trigger_template not supported") try: self.configure({"sharing": {