Fixes IndexError in Component.from_ical()

pull/179/head
Stanislav Laznicka 2016-01-21 16:22:45 +01:00
rodzic f1f4bc52db
commit 63fcf7436e
3 zmienionych plików z 16 dodań i 1 usunięć

Wyświetl plik

@ -10,6 +10,9 @@ New:
Fixes:
- Fixed possible IndexError exception during parsing of an ical string.
[stlaz]
- Fixed date-time being recognized as date or time during parsing. Added
better error handling to parsing from ical strings.
[stlaz]

Wyświetl plik

@ -362,7 +362,10 @@ class Component(CaselessDict):
# we are adding properties to the current top of the stack
else:
factory = types_factory.for_property(name)
component = stack[-1]
component = stack[-1] if stack else None
if not component:
raise ValueError('Property "{prop}" does not have '
'a parent component.'.format(prop=name))
datetime_names = ('DTSTART', 'DTEND', 'RECURRENCE-ID', 'DUE',
'FREEBUSY', 'RDATE', 'EXDATE')
try:

Wyświetl plik

@ -360,3 +360,12 @@ END:VCALENDAR"""
b'DTEND:20150905T100000Z\r\nUID:123\r\n'
b'END:VEVENT\r\nEND:VCALENDAR\r\n'
)
def test_index_error_issue(self):
"""
Found an issue where from_ical() would raise IndexError for properties
without parent components
"""
with self.assertRaises(ValueError):
cal = icalendar.Calendar.from_ical('VERSION:2.0')