entry: Die unless we're parsing a version 2.0 iCalendar
authorW. Trevor King <wking@tremily.us>
Sun, 30 Jun 2013 19:03:03 +0000 (15:03 -0400)
committerW. Trevor King <wking@tremily.us>
Sun, 30 Jun 2013 20:24:29 +0000 (16:24 -0400)
RFC 5545, section 3.7.4 (Version) describes this text field.  Until I
actually see something using using the (minver ";" maxver) syntax,
I'll just require everything to be version 2.0.

pycalendar/entry.py

index 4e5db9f6cf99b39279ffbf762286d422522d5524..46bf3b679f3b5c9d29ae509e9ff5e6e436a7bc76 100644 (file)
@@ -146,6 +146,11 @@ class Entry (dict):
                     self._add_value(key=value, value=child, force_list=True)
                     child_lines = []
             elif not stack:  # our own data, not a child's
+                if key == 'VERSION':
+                    v = _text.unescape(value)
+                    if v != '2.0':
+                        raise NotImplementedError(
+                            'cannot parse VERSION {} feed'.format(v))
                 self._add_value(key=key, value=value)
 
     def _add_value(self, key, value, force_list=False):