diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 427220ec..6a28864c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -19,6 +19,7 @@ Ics.py changelog - Added LAST-MODIFIED attribute support - Event equality now checks all fields (except uid) - alarms in Event and Todo are now consistently lists and not a mix between set() and list() + - Fix SEQUENCE in VTIMEZONE error ************** 0.4 diff --git a/ics/icalendar.py b/ics/icalendar.py index 0e612c7f..0725729f 100644 --- a/ics/icalendar.py +++ b/ics/icalendar.py @@ -19,7 +19,7 @@ ContentLine, Container, ) -from .utils import remove_x +from .utils import remove_x, remove_sequence class Calendar(Component): @@ -188,6 +188,7 @@ def timezone(calendar, vtimezones): """ for vtimezone in vtimezones: remove_x(vtimezone) # Remove non standard lines from the block + remove_sequence(vtimezone) # Remove SEQUENCE lines because tzical does not understand them fake_file = StringIO() fake_file.write(str(vtimezone)) # Represent the block as a string fake_file.seek(0) diff --git a/ics/utils.py b/ics/utils.py index 0578ea2d..23e0ebcb 100644 --- a/ics/utils.py +++ b/ics/utils.py @@ -5,7 +5,6 @@ from arrow.arrow import Arrow from datetime import timedelta -from six import StringIO, string_types, text_type, integer_types from uuid import uuid4 from dateutil.tz import gettz @@ -24,6 +23,13 @@ def remove_x(container): del container[i] +def remove_sequence(container): + for i in reversed(range(len(container))): + item = container[i] + if item.name == 'SEQUENCE': + del container[i] + + DATE_FORMATS = dict((len(k), k) for k in ( 'YYYYMM', 'YYYYMMDD', diff --git a/tests/fixture.py b/tests/fixture.py index 4b513b71..f2734698 100644 --- a/tests/fixture.py +++ b/tests/fixture.py @@ -503,6 +503,21 @@ END:VCALENDAR """ +clas33 = """ +BEGIN:VTIMEZONE +TZID:Australia/Sydney +TZURL:http://tzurl.org/zoneinfo/Australia/Sydney +SEQUENCE:498 +SEQUENCE:498 +BEGIN:STANDARD +TZOFFSETFROM:+1100 +TZOFFSETTO:+1000 +TZNAME:EST +DTSTART:20080406T030000 +RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU +END:STANDARD +""" + unfolded_cal2 = [ 'BEGIN:VCALENDAR', 'BEGIN:VEVENT', diff --git a/tests/misc.py b/tests/misc.py new file mode 100644 index 00000000..9db19e2b --- /dev/null +++ b/tests/misc.py @@ -0,0 +1,6 @@ +from ics.icalendar import Calendar +from .fixture import cal32 + + +def test_issue_90(): + Calendar(cal32)