mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	Fixed #16201 -- Ensure that requests with Content-Length=0 don't break the multipart parser. Thanks to albsen for the report and patch
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16353 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
		| @@ -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. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user