[CalendarServer-changes] [332] CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch

source_changes at macosforge.org source_changes at macosforge.org
Fri Oct 27 17:00:52 PDT 2006


Revision: 332
          http://trac.macosforge.org/projects/calendarserver/changeset/332
Author:   wsanchez at apple.com
Date:     2006-10-27 17:00:51 -0700 (Fri, 27 Oct 2006)

Log Message:
-----------
Clean up variable names in locateChildResource().
Make sure child_name doesn't contain '/'.
In locateResource(), unquote the path string, rather than unquoting all of its segments later.

Modified Paths:
--------------
    CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch

Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch	2006-10-27 23:45:21 UTC (rev 331)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.server.patch	2006-10-28 00:00:51 UTC (rev 332)
@@ -113,7 +113,16 @@
          #
          # Parse the URL
          #
-@@ -414,11 +431,53 @@
+@@ -406,19 +423,62 @@
+                 "URL is not on this site (%s://%s/): %s" % (scheme, self.headers.getHeader("host"), url)
+             ))
+ 
+-        segments = path.split("/")
++        segments = unquote(path).split("/")
+         assert segments[0] == "", "URL path didn't begin with '/': %s" % (path,)
+         segments = segments[1:]
+-        segments = map(unquote, segments)
+ 
          def notFound(f):
              f.trap(http.HTTPError)
              if f.response.code != responsecode.NOT_FOUND:
@@ -127,13 +136,13 @@
 +        d.addErrback(notFound)
 +        return d
  
-+    def locateChildResource(self, resource, child_path):
++    def locateChildResource(self, parent, child_name):
 +        """
 +        Looks up the child resource with the given name given the parent
 +        resource.  This is similar to locateResource(), but doesn't have to
 +        start the lookup from the root resource, so it is potentially faster.
-+        @param resource: the parent of the resource being looked up.
-+        @param child_path: the path of the resource being looked up, relative
++        @param parent: the parent of the resource being looked up.
++        @param child_name: the name of the child of C{parent} to looked up.
 +            to C{parent}.
 +        @return: a L{Deferred} resulting in the L{IResource} at the
 +            given URL or C{None} if no such resource can be located.
@@ -144,24 +153,26 @@
 +            The contained response will have a status code of
 +            L{responsecode.BAD_REQUEST}.
 +        """
-+        if resource is None or child_path is None:
++        if parent is None or child_name is None:
 +            return None
-+        
-+        url = joinURL(self.urlForResource(resource), child_path)
 +
++        url = joinURL(self.urlForResource(parent), child_name)
++
 +        cached = self._urlsByResource.get(url, None)
 +        if cached is not None:
 +            return succeed(cached)
 +
-+        segment = unquote(child_path)
++        assert "/" not in child_name, "Child name may not contain '/': %s" % (child_name,)
 +
++        segment = unquote(child_name)
++
 +        def notFound(f):
 +            f.trap(http.HTTPError)
 +            if f.response.code != responsecode.NOT_FOUND:
 +                return f
 +            return None
 +
-+        d = defer.maybeDeferred(self._getChild, None, resource, [segment], updatepaths=False)
++        d = defer.maybeDeferred(self._getChild, None, parent, [segment], updatepaths=False)
 +        d.addCallback(self._rememberResource, url)
 +        d.addErrback(notFound)
 +        return d

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061027/59de4e9a/attachment.html


More information about the calendarserver-changes mailing list