Fix detection of infinite recurrence

* The RRULE field might not exist.
* vobject also accepts lower case COUNT and UNTIL.
This commit is contained in:
Unrud 2017-06-07 15:31:05 +02:00
parent 82fc6f7eb6
commit 0e35ab1baf

View File

@ -284,8 +284,9 @@ def _visit_time_ranges(vobject_item, child_name, range_fn, infinity_fn):
dtstart = child.dtstart.value
if child.rruleset:
if (";UNTIL=" not in child.rrule.value and
";COUNT=" not in child.rrule.value):
if (hasattr(child, "rrule") and
";UNTIL=" not in child.rrule.value.upper() and
";COUNT=" not in child.rrule.value.upper()):
for dtstart in child.getrruleset(addRDate=True):
if infinity_fn(_date_to_datetime(dtstart)):
return
@ -357,8 +358,9 @@ def _visit_time_ranges(vobject_item, child_name, range_fn, infinity_fn):
created = _date_to_datetime(created.value)
if child.rruleset:
if (";UNTIL=" not in child.rrule.value and
";COUNT=" not in child.rrule.value):
if (hasattr(child, "rrule") and
";UNTIL=" not in child.rrule.value.upper() and
";COUNT=" not in child.rrule.value.upper()):
for reference_date in child.getrruleset(addRDate=True):
if infinity_fn(_date_to_datetime(reference_date)):
return
@ -432,8 +434,9 @@ def _visit_time_ranges(vobject_item, child_name, range_fn, infinity_fn):
if dtstart is not None:
dtstart = dtstart.value
if child.rruleset:
if (";UNTIL=" not in child.rrule.value and
";COUNT=" not in child.rrule.value):
if (hasattr(child, "rrule") and
";UNTIL=" not in child.rrule.value.upper() and
";COUNT=" not in child.rrule.value.upper()):
for dtstart in child.getrruleset(addRDate=True):
if infinity_fn(_date_to_datetime(dtstart)):
return