fix: ICS export doesn't escape commas/semicolons in event fields (#1161)

* fix: escape SUMMARY/LOCATION per RFC 5545 in ICS export

* fix: escape commas/semicolons in ICS DESCRIPTION, not just newlines

* test: ICS export escapes commas, semicolons, backslashes, newlines
This commit is contained in:
Afonso Coutinho
2026-06-02 14:36:12 +01:00
committed by GitHub
parent 2e2da2aefe
commit 5b12bf3f55
2 changed files with 46 additions and 4 deletions
+25
View File
@@ -0,0 +1,25 @@
"""Tests for iCalendar TEXT escaping in calendar export (RFC 5545 §3.3.11)."""
from tests.test_null_owner_gates import _import_calendar_helpers
def _esc():
return _import_calendar_helpers()._ics_escape
def test_escapes_comma_and_semicolon():
# Regression: SUMMARY/LOCATION escaped nothing, so a comma/semicolon
# (structural in iCal TEXT values) corrupted the field in other clients.
assert _esc()("Lunch, dinner; meeting") == "Lunch\\, dinner\\; meeting"
def test_escapes_backslash_first():
assert _esc()("path C:\\tmp") == "path C:\\\\tmp"
def test_newlines_become_literal_backslash_n():
assert _esc()("line1\nline2\r\nline3") == "line1\\nline2\\nline3"
def test_empty_and_none_safe():
assert _esc()("") == ""
assert _esc()(None) == ""