[Twisted-web] [PATCH] Unquote URI when converting to filesystem path

Wilfredo Sánchez Vega wsanchez at wsanchez.net
Fri Aug 12 16:05:46 MDT 2005


   The following patch fixes web2 to unquote a path string derived  
from a request URI before sticking into a filesystem path.   
Otherwise, URIs like "/foo%20bar" don't get properly translated to "/ 
foo bar".

     -wsv


Index: twisted/web2/static.py
===================================================================
--- twisted/web2/static.py      (revision 14235)
+++ twisted/web2/static.py      (working copy)
@@ -6,7 +6,7 @@
"""
# System Imports
-import os, time, stat
+import os, time, stat, urllib
# Sibling Imports
from twisted.web2 import http_headers, resource
@@ -177,7 +177,7 @@
              return None, ()
          if path:
-            fpath = self.fp.child(path)
+            fpath = self.fp.child(urllib.unquote(path))
          else:
              fpath = self.fp.childSearchPreauth(*self.indexNames)
              if fpath is None:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3057 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-web/attachments/20050812/39976be5/smime.bin


More information about the Twisted-web mailing list