diff options
author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-08-12 12:02:08 +0000 |
---|---|---|
committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-08-12 12:02:08 +0000 |
commit | 3757f30c99838783402b54d1cfd41958d1493aad (patch) | |
tree | ce916fdacde6d4ddef12b2f9cbbf6ce1ecdff668 /django/utils/datastructures.py | |
parent | 78dfdd5648d0fc6060e03a2edbe738779d132684 (diff) | |
download | django-3757f30c99838783402b54d1cfd41958d1493aad.tar.gz |
Fixed #4947 -- Avoid displaying uploaded file contents in the debug web page. Based on a patch from eibaan@gmail.com.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5874 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/datastructures.py')
-rw-r--r-- | django/utils/datastructures.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index 60bc0051a2..4b60d1d194 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -267,3 +267,16 @@ class DotExpandedDict(dict): current[bits[-1]] = v except TypeError: # Special-case if current isn't a dict. current = {bits[-1] : v} + +class FileDict(dict): + """ + A dictionary used to hold uploaded file contents. The only special feature + here is that repr() of this object won't dump the entire contents of the + file to the output. A handy safeguard for a large file upload. + """ + def __repr__(self): + if 'content' in self: + d = dict(self, content='<omitted>') + return dict.__repr__(d) + return dict.__repr__(self) + |