From f1d84cea358fbeb31753834c3cd816a2225ff292 Mon Sep 17 00:00:00 2001 From: Will Sowerbutts Date: Thu, 11 Jul 2024 13:38:48 +0100 Subject: [PATCH] Remove unexpected control codes from ICS files --- radicale/item/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/radicale/item/__init__.py b/radicale/item/__init__.py index c5a32690..c10824a6 100644 --- a/radicale/item/__init__.py +++ b/radicale/item/__init__.py @@ -49,6 +49,12 @@ def read_components(s: str) -> List[vobject.base.Component]: s = re.sub(r"^(PHOTO(?:;[^:\r\n]*)?;ENCODING=b(?:;[^:\r\n]*)?:)" r"data:[^;,\r\n]*;base64,", r"\1", s, flags=re.MULTILINE | re.IGNORECASE) + # Workaround for bug with malformed ICS files containing control codes + # Filter out all control codes except those we expect to find: + # * 0x09 Horizontal Tab + # * 0x0A Line Feed + # * 0x0D Carriage Return + s = re.sub(r'[\x00-\x08\x0B\x0C\x0E-\x1F]', '', s) return list(vobject.readComponents(s, allowQP=True))