Просмотр исходного кода

Merge pull request #631 from Unrud/improveerrors

Detect errors in recurrence rules early
Unrud 8 лет назад
Родитель
Сommit
578d0e1376
2 измененных файлов с 18 добавлено и 2 удалено
  1. 9 2
      radicale/storage.py
  2. 9 0
      radicale/xmlutils.py

+ 9 - 2
radicale/storage.py

@@ -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")

+ 9 - 0
radicale/xmlutils.py

@@ -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