diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2011-08-23 15:57:01 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2011-08-23 15:57:01 +0000 |
| commit | e2d7a784c8aa56883a84ba536bc4ba4803fcb94e (patch) | |
| tree | 25a8253164d16a71f7a1c09b4cd25fd5d64b6b15 /django | |
| parent | f317bd20d762616ad5cf502c59eb55835a75056a (diff) | |
[1.3.X] Fixed #16201 -- Ensure that requests with Content-Length=0 don't break the multipart parser. Thanks to albsen for the report and patch
Backport of r16353 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@16676 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/http/multipartparser.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py index e45d5d1035..e3a03ff897 100644 --- a/django/http/multipartparser.py +++ b/django/http/multipartparser.py @@ -75,7 +75,7 @@ class MultiPartParser(object): # For now set it to 0; we'll try again later on down. content_length = 0 - if content_length <= 0: + if content_length < 0: # This means we shouldn't continue...raise an error. raise MultiPartParserError("Invalid content length: %r" % content_length) @@ -105,6 +105,11 @@ class MultiPartParser(object): encoding = self._encoding handlers = self._upload_handlers + # HTTP spec says that Content-Length >= 0 is valid + # handling content-length == 0 before continuing + if self._content_length == 0: + return QueryDict(MultiValueDict(), encoding=self._encoding), MultiValueDict() + limited_input_data = LimitBytes(self._input_data, self._content_length) # See if the handler will want to take care of the parsing. |
