kopia lustrzana https://github.com/collective/icalendar
Fixes IndexError in Component.from_ical()
rodzic
f1f4bc52db
commit
63fcf7436e
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue