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

Changeset 561

Show
Ignore:
Timestamp:
08/27/05 12:32:59
Author:
fumanchu
Message:

1. Partial fix for #248; the request path is now %XX-decoded as soon as possible (was in mapPathToObject). This means config sections can now be decoded, as well (e.g. you should now write path instead of /this%20path).
2. Changeset [559] broke logging test--fixed.

Files:

Legend:

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

    r559 r561  
    258258            path, req.queryString = path, "" 
    259259         
    260         # See http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2 
     260        # Unquote the path (e.g. "/this%20path" -> "this path"). 
     261        # http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2 
     262        # Note that cgi.parse_qs will decode the querystring for us. 
     263        path = urllib.unquote(path) 
     264         
    261265        if path == "*": 
     266            # "...the request does not apply to a particular resource, 
     267            # but to the server itself". See 
     268            # http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2 
    262269            path = "global" 
    263270        elif not path.startswith("/"): 
     
    851858    # Remove leading and trailing slash 
    852859    tpath = path.strip("/") 
    853     # Replace quoted chars (eg %20) from url 
    854     tpath = urllib.unquote(tpath) 
    855860     
    856861    if not tpath: 
  • trunk/cherrypy/test/test_core.py

    r558 r561  
    6767    def ismap(self, x, y): 
    6868        return "Coordinates: %s, %s" % (x, y) 
     69     
     70    def default(self, *args, **kwargs): 
     71        return "args: %s kwargs: %s" % (args, kwargs) 
    6972 
    7073 
     
    267270        'server.logAccessFile': logAccessFile, 
    268271    }, 
     272    '/params': { 
     273        'server.logFile': logFile, 
     274    }, 
    269275}) 
    270276 
     
    311317            ignore.pop() 
    312318         
     319        # Test "% HEX HEX"-encoded URL, param keys, and values 
     320        self.getPage("/params/%e3/cheese?Gruy%E8re=Bulgn%e9ville") 
     321        self.assertBody(r"args: ('\xe3', 'cheese') " 
     322                        r"kwargs: {'Gruy\xe8re': 'Bulgn\xe9ville'}") 
     323         
     324        # Make sure that encoded = and & get parsed correctly 
     325        self.getPage("/params/code?url=http%3A//cherrypy.org/index%3Fa%3D1%26b%3D2") 
     326        self.assertBody(r"args: ('code',) " 
     327                        r"kwargs: {'url': 'http://cherrypy.org/index?a=1&b=2'}") 
     328         
    313329        # Test coordinates sent by <img ismap> 
    314330        self.getPage("/params/ismap?223,114") 
     
    347363        self.assertBody('content') 
    348364        self.assertStatus('200 OK') 
    349          
    350         data = open(logFile, "rb").readlines() 
    351         self.assertEqual(data[0][-55:], ' HTTP INFO 127.0.0.1 - GET /flatten/as_string HTTP/1.1\n') 
    352         self.assertEqual(data[1][-54:], ' HTTP INFO 127.0.0.1 - GET /flatten/as_yield HTTP/1.1\n') 
    353365         
    354366        data = open(logAccessFile, "rb").readlines() 
     
    372384        else: 
    373385            self.assertEqual(data[1][-41:], '] "GET /flatten/as_yield HTTP/1.1" 200 -\n') 
     386         
     387        data = open(logFile, "rb").readlines() 
     388        self.assertEqual(data, []) 
     389         
     390        # Test that error log gets access messages if no logAccess defined. 
     391        self.getPage("/params/?thing=a") 
     392        self.assertBody("'a'") 
     393        data = open(logFile, "rb").readlines() 
     394        self.assertEqual(data[0][-53:], ' HTTP INFO 127.0.0.1 - GET /params/?thing=a HTTP/1.1\n') 
    374395     
    375396    def testRedirect(self): 
  • trunk/cherrypy/test/test_objectmapping.py

    r552 r561  
    144144         
    145145        # Test that we can use URL's which aren't all valid Python identifiers 
    146         self.getPage("/Von%20B\xfclow?ID=14") 
     146        # This should also test the %XX-unquoting of URL's. 
     147        self.getPage("/Von%20B%fclow?ID=14") 
    147148        self.assertBody("ID is 14") 
    148149 

Hosted by WebFaction

Log in as guest/cpguest to create tickets