Revision
6478
Author
cdaboo@apple.com
Date
2010-10-27 18:49:29 -0700 (Wed, 27 Oct 2010)

Log Message

Make sure direct shares use canonical __uids__ paths.

Modified Paths

Diff

Modified: CalendarServer/trunk/twext/web2/dav/resource.py (6477 => 6478)


--- CalendarServer/trunk/twext/web2/dav/resource.py	2010-10-28 01:45:42 UTC (rev 6477)
+++ CalendarServer/trunk/twext/web2/dav/resource.py	2010-10-28 01:49:29 UTC (rev 6478)
@@ -725,14 +725,12 @@
         for childname in childnames:
             childpath = joinURL(basepath, urllib.quote(childname))
             child = (yield request.locateChildResource(self, childname))
-            if child.isCollection():
-                collections1.append((child, childpath + "/"))
-            if names and childname not in names1:
-                continue
-            if child is None:
-                children.append((None, childpath + "/"))
-            else:
+            if child is not None:
                 if child.isCollection():
+                    collections1.append((child, childpath + "/"))
+                if names and childname not in names1:
+                    continue
+                if child.isCollection():
                     children.append((child, childpath + "/"))
                 else:
                     children.append((child, childpath))

Modified: CalendarServer/trunk/twistedcaldav/sharing.py (6477 => 6478)


--- CalendarServer/trunk/twistedcaldav/sharing.py	2010-10-28 01:45:42 UTC (rev 6477)
+++ CalendarServer/trunk/twistedcaldav/sharing.py	2010-10-28 01:49:29 UTC (rev 6478)
@@ -196,7 +196,7 @@
             ))
 
         # Accept it
-        response = (yield home.acceptDirectShare(request, request.path, self.resourceID(), self.displayName()))
+        response = (yield home.acceptDirectShare(request, compareURL, self.resourceID(), self.displayName()))
 
         # Return the URL of the shared calendar
         returnValue(response)

Modified: CalendarServer/trunk/txdav/common/datastore/sql_legacy.py (6477 => 6478)


--- CalendarServer/trunk/txdav/common/datastore/sql_legacy.py	2010-10-28 01:45:42 UTC (rev 6477)
+++ CalendarServer/trunk/txdav/common/datastore/sql_legacy.py	2010-10-28 01:49:29 UTC (rev 6478)
@@ -520,6 +520,11 @@
     def addOrUpdateRecord(self, record):
         # record.hosturl -> /.../__uids__/<uid>/<name>
         splithost = record.hosturl.split('/')
+        
+        # Double-check the path
+        if splithost[2] != "__uids__":
+            raise ValueError("Sharing URL must be a __uids__ path: %s" % (record.hosturl,))
+            
         ownerUID = splithost[3]
         ownerCollectionName = splithost[4]
         ownerHome = yield self._getHomeWithUID(ownerUID)