[Calypso] Incorrect parsing of rrule?

Petter Reinholdtsen pere at hungry.com
Sun Jan 24 13:59:24 PST 2016


[Guido Günther]
> Hi Petter,

Hi.

> this looks pretty much like your exception.

Yes.

>> Is the problem perhaps that the <time-range> xml tag is missing an end
>> tag?  Is this required by the protocol?
>
> https://tools.ietf.org/html/rfc4791#section-9.9
>
> says that one element is sufficient. Assuming -∞ or +∞ respectively. Can
> you cook up a patch to fix this and at tests that we don't regress
> later?

Right.  Thank you for the standard reference.  The following patch solve
the issue I am seing with korganizer, but I am unsure how to write the
test.

diff --git a/calypso/xmlutils.py b/calypso/xmlutils.py
index e94a5e9..3ce5ba5 100644
--- a/calypso/xmlutils.py
+++ b/calypso/xmlutils.py
@@ -275,6 +275,12 @@ def match_filter_element(vobject, fe):
             return False
         start = fe.get("start")
         end = fe.get("end")
+        # RFC 4791 state if start is missing, assume it is -infinity
+        if start is None:
+            start = "00010101T000000Z" # start of year zero
+        # RFC 4791 state if end is missing, assume it is +infinity
+        if end is None:
+            end = "99991231T235959Z" # last date with four digit year
         if rruleset is None:
             rruleset = dateutil.rrule.rruleset()
             dtstart = vobject.dtstart.value

I tried this test, but it do not produce a backtrace even if my fix is
not present, so it is not testing what I hoped it would be testing.

diff --git a/tests/test_collection.py b/tests/test_collection.py
index feda9a0..3a61a29 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -2,6 +2,7 @@
 """Test L{gbp.command_wrappers.Command}'s tarball unpack"""
 
 import os
+import sys
 import subprocess
 import tempfile
 import shutil
@@ -9,10 +10,13 @@ import unittest
 
 import calypso.config
 from calypso.webdav import Collection
+from calypso import xmlutils
+from calypso import paths
 
 
 class TestCollection(unittest.TestCase):
     test_vcard = "tests/data/import.vcard"
+    test_vcal = "tests/data/import.vcal"
 
     def setUp(self):
         self.tmpdir = tempfile.mkdtemp()
@@ -29,3 +33,30 @@ class TestCollection(unittest.TestCase):
         self.assertEqual(len(collection.items), 2)
         org = u'Universitetet i Tromsø'
         self.assertTrue(org == collection.items[0].object.org.value[0])
+
+    def test_report(self):
+        xml_request ="""
+<calendar-query xmlns="urn:ietf:params:xml:ns:caldav">
+ <prop xmlns="DAV:">
+  <getetag xmlns="DAV:"/>
+  <resourcetype xmlns="DAV:"/>
+ </prop>
+ <filter xmlns="urn:ietf:params:xml:ns:caldav">
+  <comp-filter xmlns="urn:ietf:params:xml:ns:caldav" name="VCALENDAR">
+   <comp-filter xmlns="urn:ietf:params:xml:ns:caldav" name="VTODO">
+    <time-range xmlns="urn:ietf:params:xml:ns:caldav" start="20151021T201004Z"/>
+   </comp-filter>
+  </comp-filter>
+ </filter>
+</calendar-query>
+"""
+        collection = Collection("")
+        self.assertTrue(collection.import_file(self.test_vcal))
+        path = paths.base_prefix()
+
+        # Tried calling do_REPORT() directly, but lacked the arguments
+        # needed to get the CollectionHTTPHandler class working.
+        answer = xmlutils.report(path, xml_request, collection)
+
+        sys.stderr.write("REPORT " + answer)
+

Anyone with clues to spare?

-- 
Happy hacking
Petter Reinholdtsen


More information about the Calypso mailing list