-
-
Notifications
You must be signed in to change notification settings - Fork 195
Open
Description
Describe the bug
When a text, e.g. x\\x is made into an ics string and then parsed, it looses half the \.
To reproduce
This is a bit confusing but the problem is with the ICS. You cannot trust your eye, see below!
>>> import icalendar
>>> cal = icalendar.Calendar()
>>> cal.calendar_name = b = r"\\\\\\" # COUNT: 6
>>> cal2 = icalendar.Calendar.from_ical(cal.to_ical())
>>> cal2.calendar_name == b
False
>>> cal2.calendar_name
vText(b'\\\\\\\\\\\\') # COUNT: 3 ???
>>> len(cal2.calendar_name), len(b)
(3, 6)
>>> str(cal2.calendar_name), len(str(cal2.calendar_name))
('\\\\\\', 3) # COUNT 3
>>> cal.to_ical()
b'BEGIN:VCALENDAR\r\nNAME:\\\\\\\\\\\\\\\\\\\\\\\\\r\nEND:VCALENDAR\r\n'
>>> print(cal.to_ical().decode())
BEGIN:VCALENDAR
NAME:\\\\\\\\\\\\ # COUNT 12
END:VCALENDARExpected behavior
The count of backslashes should stay the same.
Environment
- Operating system: independent
- Python version: 3.11
-
icalendarversion: main@3afba5d8d6748e786ebd85522dd8309c23054045
Additional context
Found here:
To close the issue
- fix the test cases in 72c02c7
Metadata
Metadata
Assignees
Labels
No labels