Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 826

Show
Ignore:
Timestamp:
11/16/05 12:46:17
Author:
fumanchu
Message:

Fix for #393 (in trunk).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cphttptools.py

    r823 r826  
    219219                page_handler, object_path, virtual_path = self.mapPathToObject(path) 
    220220                 
     221                # Decode any leftover %2F in the virtual_path atoms. 
     222                virtual_path = [x.replace("%2F", "/") for x in virtual_path] 
     223                 
    221224                # Remove "root" from object_path and join it to get objectPath 
    222225                self.objectPath = '/' + '/'.join(object_path[1:]) 
  • trunk/cherrypy/lib/httptools.py

    r819 r826  
    311311        # Unquote the path (e.g. "/this%20path" -> "this path"). 
    312312        # http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2 
    313         # Note that cgi.parse_qs will decode the querystring for us. 
    314         path = urllib.unquote(path) 
     313        # 
     314        # But note that "...a URI must be separated into its components 
     315        # before the escaped characters within those components can be 
     316        # safely decoded." http://www.ietf.org/rfc/rfc2396.txt, sec 2.4.2 
     317        # 
     318        # Note also that cgi.parse_qs will decode the querystring for us. 
     319        atoms = [urllib.unquote(x) for x in re.split("(?i)%2F", path)] 
     320        path = "%2F".join(atoms) 
    315321     
    316322    return method, path, qs, protocol 
  • trunk/cherrypy/test/test_objectmapping.py

    r795 r826  
    145145        self.assertBody("ID is 14") 
    146146         
     147        # Test that %2F in the path doesn't get unquoted too early; 
     148        # that is, it should not be used to separate path components. 
     149        # See ticket #393. 
     150        self.getPage("/page%2Fname") 
     151        self.assertBody("default:('page/name',)") 
     152     
    147153    def testPositionalParams(self): 
    148154        self.getPage("/dir1/dir2/posparam/18/24/hut/hike") 

Hosted by WebFaction

Log in as guest/cpguest to create tickets