diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2006-09-25 07:25:12 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2006-09-25 07:25:12 +0000 |
| commit | f1c63992f77cd764239a09a6abe26a2781b34388 (patch) | |
| tree | b8ec036c022f476c0508e21d5d13f585c0211762 /django/core/handlers/modpython.py | |
| parent | 5b490bba93d03edc58f0903d5ebb75f7b0f44784 (diff) | |
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.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3820 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core/handlers/modpython.py')
| -rw-r--r-- | django/core/handlers/modpython.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py index db3c33147b..41d9a578c5 100644 --- a/django/core/handlers/modpython.py +++ b/django/core/handlers/modpython.py @@ -16,9 +16,26 @@ class ModPythonRequest(http.HttpRequest): self.path = req.uri def __repr__(self): + # Since this is called as part of error handling, we need to be very + # robust against potentially malformed input. + try: + get = pformat(self.GET) + except: + get = '<could not parse>' + try: + post = pformat(self.POST) + except: + post = '<could not parse>' + try: + cookies = pformat(self.COOKIES) + except: + cookies = '<could not parse>' + try: + meta = pformat(self.META) + except: + meta = '<could not parse>' return '<ModPythonRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \ - (self.path, pformat(self.GET), pformat(self.POST), pformat(self.COOKIES), - pformat(self.META)) + (self.path, get, post, cookies, meta) def get_full_path(self): return '%s%s' % (self.path, self._req.args and ('?' + self._req.args) or '') |
