From f93190551794303bae40eb266b1af7b353186931 Mon Sep 17 00:00:00 2001 From: James Bennett Date: Fri, 24 Nov 2006 18:24:49 +0000 Subject: [PATCH] 0.91-bugfixes: Backport [3820] to 0.91-bugfixes, refs #2745. git-svn-id: http://code.djangoproject.com/svn/django/branches/0.91-bugfixes@4099 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/handlers/wsgi.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py index 7541a5fd9d..5120ef6637 100644 --- a/django/core/handlers/wsgi.py +++ b/django/core/handlers/wsgi.py @@ -55,9 +55,30 @@ class WSGIRequest(httpwrappers.HttpRequest): def __repr__(self): from pprint import pformat - return '' % \ - (pformat(self.GET), pformat(self.POST), pformat(self.COOKIES), - pformat(self.META)) + # 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 = '' + try: + post = pformat(self.POST) + except: + post = '' + try: + cookies = pformat(self.COOKIES) + except: + cookies = '' + try: + meta = pformat(self.META) + except: + meta = '' + try: + user = self.user + except: + user = '' + return '' % \ + (self.path, get, post, cookies, meta, user) def get_full_path(self): return '%s%s' % (self.path, self.environ['QUERY_STRING'] and ('?' + self.environ['QUERY_STRING']) or '')