Merge pull request #631 from Unrud/improveerrors

Detect errors in recurrence rules early
This commit is contained in:
Unrud 2017-06-07 22:15:13 +02:00 committed by GitHub
commit 578d0e1376
2 changed files with 18 additions and 2 deletions

View File

@ -118,9 +118,16 @@ def check_item(vobject_item):
"""Check vobject items for common errors."""
if vobject_item.name == "VCALENDAR":
for component in vobject_item.components():
if (component.name in ("VTODO", "VEVENT", "VJOURNAL") and
not get_uid(component)):
if component.name not in ("VTODO", "VEVENT", "VJOURNAL"):
continue
if not get_uid(component):
raise ValueError("UID in %s is missing" % component.name)
# vobject interprets recurrence rules on demand
try:
component.rruleset
except Exception as e:
raise ValueError("invalid recurrence rules in %s" %
component.name) from e
elif vobject_item.name == "VCARD":
if not get_uid(vobject_item):
raise ValueError("UID in VCARD is missing")

View File

@ -278,6 +278,15 @@ def _visit_time_ranges(vobject_item, child_name, range_fn, infinity_fn):
"""
child = getattr(vobject_item, child_name.lower())
# TODO: Recurrences specified with RDATE
# (http://www.kanzaki.com/docs/ical/rdate.html) don't seem to work
# correct in VObject. getrruleset(addRDate=True) returns an empty generator
# if they are used.
# TODO: Single recurrences can be overwritten by components with
# RECURRENCE-ID (http://www.kanzaki.com/docs/ical/recurrenceId.html). They
# are currently ignored but can change the start and end time.
# Comments give the lines in the tables of the specification
if child_name == "VEVENT":
# TODO: check if there's a timezone