Django

Code

Changeset 3820

Show
Ignore:
Timestamp:
09/25/06 02:25:12 (2 years ago)
Author:
mtredinnick
Message:

Fixed #2745 -- Made the repr methods for modpython and wsgi request more
robust in the face of bad input, since they are needed for error handling.
Based on a patch from md@hudora.de.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/handlers/modpython.py

    r3791 r3820  
    1717 
    1818    def __repr__(self): 
     19        # Since this is called as part of error handling, we need to be very 
     20        # robust against potentially malformed input. 
     21        try: 
     22            get = pformat(self.GET) 
     23        except: 
     24            get = '<could not parse>' 
     25        try: 
     26            post = pformat(self.POST) 
     27        except: 
     28            post = '<could not parse>' 
     29        try: 
     30            cookies = pformat(self.COOKIES) 
     31        except: 
     32            cookies = '<could not parse>' 
     33        try: 
     34            meta = pformat(self.META) 
     35        except: 
     36            meta = '<could not parse>' 
    1937        return '<ModPythonRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \ 
    20             (self.path, pformat(self.GET), pformat(self.POST), pformat(self.COOKIES), 
    21             pformat(self.META)) 
     38            (self.path, get, post, cookies, meta) 
    2239 
    2340    def get_full_path(self): 
  • django/trunk/django/core/handlers/wsgi.py

    r3807 r3820  
    7979 
    8080    def __repr__(self): 
     81        # Since this is called as part of error handling, we need to be very 
     82        # robust against potentially malformed input. 
     83        try: 
     84            get = pformat(self.GET) 
     85        except: 
     86            get = '<could not parse>' 
     87        try: 
     88            post = pformat(self.POST) 
     89        except: 
     90            post = '<could not parse>' 
     91        try: 
     92            cookies = pformat(self.COOKIES) 
     93        except: 
     94            cookies = '<could not parse>' 
     95        try: 
     96            meta = pformat(self.META) 
     97        except: 
     98            meta = '<could not parse>' 
    8199        return '<WSGIRequest\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \ 
    82             (pformat(self.GET), pformat(self.POST), pformat(self.COOKIES), 
    83             pformat(self.META)) 
     100            (get, post, cookies, meta) 
    84101 
    85102    def get_full_path(self):