Handle collections with paths of depth greater 2.
authorRene Wagner <rw@nelianur.org>
Tue, 7 Feb 2012 09:59:16 +0000 (10:59 +0100)
committerKeith Packard <keithp@keithp.com>
Tue, 7 Feb 2012 16:14:55 +0000 (08:14 -0800)
Previously, calendar URLs such as /user/calendars/work
would lead to files being written in /user/calendars
and not being checked into Git.

Signed-off-by: Rene Wagner <rw@nelianur.org>
calypso/__init__.py

index ebd57ce49a0b970486be7bbcae80ad201eb1fd6c..ce4a937fcfbb1ca9910b825a0c7f7c371cd54c83 100644 (file)
@@ -177,7 +177,7 @@ class CollectionHTTPHandler(server.BaseHTTPRequestHandler):
         # ``normpath`` should clean malformed and malicious request paths
         attributes = posixpath.normpath(self.path.strip("/")).split("/")
         if len(attributes) >= 2:
-            path = "%s/%s" % (attributes[0], attributes[1])
+            path = '/'.join(attributes[:-1])
             if not path in CollectionHTTPHandler.collections:
                 CollectionHTTPHandler.collections[path] = webdav.Collection(path)
             return CollectionHTTPHandler.collections[path]