Kozea / Radicale

A simple CalDAV (calendar) and CardDAV (contact) server.
https://radicale.org
GNU General Public License v3.0
3.26k stars 426 forks source link

Unsupported TZID parm #1332

Open mdrovdahl opened 11 months ago

mdrovdahl commented 11 months ago

I'm working with some .ics files generated by an online platform (teamsnap.com) that include a TZID component that is causing Radicale (actually vobject) to error:

Sample .ics

BEGIN:VCALENDAR
PRODID;X-RICAL-TZSOURCE=TZINFO:-//com.denhaven2/NONSGML ri_cal gem//EN
CALSCALE:GREGORIAN
VERSION:2.0
X-WR-CALNAME:Bainbridge Island FC B08 White
X-WR-CALDESC:The event schedule for the Bainbridge Island FC B08 White So
 ccer team
X-WR-TIMEZONE:America/Los_Angeles
X-PUBLISHED-TTL:PT1H
X-TS-TIMESTAMP:2023-09-19 11:53:05
BEGIN:VEVENT
DTEND;TZID=America/Los_Angeles;VALUE=DATE-TIME:20230626T190000
DTSTART;TZID=America/Los_Angeles;VALUE=DATE-TIME:20230626T173000
DTSTAMP;VALUE=DATE-TIME:20230611T002230Z
LAST-MODIFIED;VALUE=DATE-TIME:20230611T002230Z
DESCRIPTION:(Arrival Time:  5:21 PM (Pacific Time (US & Canada))) 
SUMMARY:Soccer team B08 White - B08 Training
LOCATION:High School Turf
SEQUENCE:0
UID:347d986b3625741bd5bdfbb1b4480f314d31d98e784bb3bd5f1a75bc60d3a26c
END:VEVENT
BEGIN:VTIMEZONE
TZID;X-RICAL-TZSOURCE=TZINFO:America/Los_Angeles
BEGIN:DAYLIGHT
DTSTART:20230312T020000
RDATE:20230312T020000
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
TZNAME:PDT
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20231105T020000
RDATE:20231105T020000
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
TZNAME:PST
END:STANDARD
END:VTIMEZONE

I spent a fair bit searching for related issues (like this https://github.com/ics-py/ics-py/issues/268). My workaround, for now, is to modify read.components():

https://github.com/Kozea/Radicale/blob/d7ce2f0b98589400b0e1718cfd7bb29b7ebeaebe/radicale/item/__init__.py#L45

to include:

    # Workaround for bug in Timezone data
    s = re.sub(r"(TZID;X-RICAL-TZSOURCE=TZINFO:)", r"TZID:", s)
da4089 commented 5 months ago

This ICS file (with the addition of an "END:VCALENDAR" line, which I assume got lost in cut&paste), passes RFC-5545 validation at https://icalendar.org/validator.html.

vObject raises:

Error
Traceback (most recent call last):
  File "/Users/d/work/personal/vobject/vobject/base.py", line 185, in transformToNative
    return self.behavior.transformToNative(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/d/work/personal/vobject/vobject/icalendar.py", line 1093, in transformToNative
    obj.registerTzinfo(obj.tzinfo)
                       ^^^^^^^^^^
  File "/Users/d/work/personal/vobject/vobject/icalendar.py", line 159, in gettzinfo
    return tz.tzical(buffer).get()
           ^^^^^^^^^^^^^^^^^
  File "/Users/d/work/personal/vobject/venv312/lib/python3.12/site-packages/dateutil/tz/tz.py", line 1279, in __init__
    self._parse_rfc(fobj.read())
  File "/Users/d/work/personal/vobject/venv312/lib/python3.12/site-packages/dateutil/tz/tz.py", line 1443, in _parse_rfc
    raise ValueError(
ValueError: unsupported TZID parm: =TZINFO

Those last two lines show the issue originating in dateutil, and looking at the relevant function, it has:

if name == "TZID":
    if parms:
        raise ValueError(
            "unsupported TZID parm: "+parms[0])
    tzid = value

This reflects the conclusion in ics-py/ics-py#268 (as referenced above). So this needs either a fix to dateutil or some sort of work-around (in vObject).