mirror of https://github.com/django/django.git
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
This commit is contained in:
parent
5b490bba93
commit
f1c63992f7
|
@ -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 '')
|
||||
|
|
|
@ -78,9 +78,26 @@ class WSGIRequest(http.HttpRequest):
|
|||
self.method = environ['REQUEST_METHOD'].upper()
|
||||
|
||||
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 '<WSGIRequest\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \
|
||||
(pformat(self.GET), pformat(self.POST), pformat(self.COOKIES),
|
||||
pformat(self.META))
|
||||
(get, post, cookies, meta)
|
||||
|
||||
def get_full_path(self):
|
||||
return '%s%s' % (self.path, self.environ.get('QUERY_STRING', '') and ('?' + self.environ.get('QUERY_STRING', '')) or '')
|
||||
|
|
Loading…
Reference in New Issue