Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit f93190551794303bae40eb266b1af7b353186931 1 parent 2823775
James Bennett authored November 24, 2006

Showing 1 changed file with 24 additions and 3 deletions. Show diff stats Hide diff stats

  1. 27  django/core/handlers/wsgi.py
27  django/core/handlers/wsgi.py
@@ -55,9 +55,30 @@ def __init__(self, environ):
55 55
 
56 56
     def __repr__(self):
57 57
         from pprint import pformat
58  
-        return '<DjangoRequest\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \
59  
-            (pformat(self.GET), pformat(self.POST), pformat(self.COOKIES),
60  
-            pformat(self.META))
  58
+        # Since this is called as part of error handling, we need to be very
  59
+        # robust against potentially malformed input.
  60
+        try:
  61
+            get = pformat(self.GET)
  62
+        except:
  63
+            get = '<could not parse>'
  64
+        try:
  65
+            post = pformat(self.POST)
  66
+        except:
  67
+            post = '<could not parse>'
  68
+        try:
  69
+            cookies = pformat(self.COOKIES)
  70
+        except:
  71
+            cookies = '<could not parse>'
  72
+        try:
  73
+            meta = pformat(self.META)
  74
+        except:
  75
+            meta = '<could not parse>'
  76
+        try:
  77
+            user = self.user
  78
+        except:
  79
+            user = '<could not parse>'
  80
+        return '<DjangoRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s,\nuser:%s>' % \
  81
+               (self.path, get, post, cookies, meta, user)
61 82
 
62 83
     def get_full_path(self):
63 84
         return '%s%s' % (self.path, self.environ['QUERY_STRING'] and ('?' + self.environ['QUERY_STRING']) or '')

0 notes on commit f931905

Please sign in to comment.
Something went wrong with that request. Please try again.