Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
Handle escaped URIs (e.g. %20) by unquoting them during the path segm…
Browse files Browse the repository at this point in the history
…ent scanning, and then

quoting them when registering the resource->URI mapping. Note this is not ideal: what we really
should do is leave URIs quoted all the time, and then in the static.py files do the unquoting
of the segment path to generate the actual file path - or perhaps not even both with that - i.e.
allow the files to be stored with the quoted characters in place. That may be better because it
avoids issues of unicode normalization etc that can occur with an arbitrary file system if we
ever get to support IRIs.

git-svn-id: https://svn.calendarserver.org/repository/calendarserver/CalendarServer/branches/users/cdaboo/acl-merge@81 e27351fd-9f3e-4f54-a53b-843176b1656c
  • Loading branch information
cyrusdaboo committed Aug 30, 2006
1 parent 979a8f8 commit 080680f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions patches/Twisted/twisted.web2.server.patch
Expand Up @@ -2,12 +2,21 @@ Index: twisted/web2/server.py
===================================================================
--- twisted/web2/server.py (revision 17932)
+++ twisted/web2/server.py (working copy)
@@ -11,7 +11,7 @@
import cStringIO as StringIO

import cgi, time, urlparse
-from urllib import unquote
+from urllib import quote, unquote
from urlparse import urlsplit

import weakref
@@ -316,7 +316,7 @@
if newpath is StopTraversal:
# We need to rethink how to do this.
#if newres is res:
- self._rememberURLForResource(path, res)
+ self.rememberURLForResource(path, res)
+ self.rememberURLForResource(quote(path), res)
return res
#else:
# raise ValueError("locateChild must not return StopTraversal with a resource other than self.")
Expand All @@ -16,7 +25,7 @@ Index: twisted/web2/server.py

child = self._getChild(None, newres, newpath, updatepaths=updatepaths)
- self._rememberURLForResource(url, child)
+ self.rememberURLForResource(url, child)
+ self.rememberURLForResource(quote(url), child)

return child

Expand All @@ -29,3 +38,11 @@ Index: twisted/web2/server.py
"""
Remember the URL of visited resources.
"""
@@ -404,6 +404,7 @@
segments = 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)

0 comments on commit 080680f

Please sign in to comment.