mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	[1.10.x] Fixed #27005 -- Fixed crash if request.META[''CONTENT_LENGTH']=''.
Backport of 5c63b3e5a7 from master
			
			
This commit is contained in:
		| @@ -264,7 +264,7 @@ class HttpRequest(object): | |||||||
|  |  | ||||||
|             # Limit the maximum request data size that will be handled in-memory. |             # Limit the maximum request data size that will be handled in-memory. | ||||||
|             if (settings.DATA_UPLOAD_MAX_MEMORY_SIZE is not None and |             if (settings.DATA_UPLOAD_MAX_MEMORY_SIZE is not None and | ||||||
|                     int(self.META.get('CONTENT_LENGTH', 0)) > settings.DATA_UPLOAD_MAX_MEMORY_SIZE): |                     int(self.META.get('CONTENT_LENGTH') or 0) > settings.DATA_UPLOAD_MAX_MEMORY_SIZE): | ||||||
|                 raise RequestDataTooBig('Request body exceeded settings.DATA_UPLOAD_MAX_MEMORY_SIZE.') |                 raise RequestDataTooBig('Request body exceeded settings.DATA_UPLOAD_MAX_MEMORY_SIZE.') | ||||||
|  |  | ||||||
|             try: |             try: | ||||||
|   | |||||||
| @@ -23,3 +23,6 @@ Bugfixes | |||||||
|  |  | ||||||
| * Fixed a regression in the number of queries when using ``RadioSelect`` with a | * Fixed a regression in the number of queries when using ``RadioSelect`` with a | ||||||
|   ``ModelChoiceField`` form field (:ticket:`27001`). |   ``ModelChoiceField`` form field (:ticket:`27001`). | ||||||
|  |  | ||||||
|  | * Fixed a crash if ``request.META['CONTENT_LENGTH']`` is an empty string | ||||||
|  |   (:ticket:`27005`). | ||||||
|   | |||||||
| @@ -104,6 +104,10 @@ class DataUploadMaxMemorySizeGetTests(SimpleTestCase): | |||||||
|         with self.settings(DATA_UPLOAD_MAX_MEMORY_SIZE=None): |         with self.settings(DATA_UPLOAD_MAX_MEMORY_SIZE=None): | ||||||
|             self.request.body |             self.request.body | ||||||
|  |  | ||||||
|  |     def test_empty_content_length(self): | ||||||
|  |         self.request.environ['CONTENT_LENGTH'] = '' | ||||||
|  |         self.request.body | ||||||
|  |  | ||||||
|  |  | ||||||
| class DataUploadMaxNumberOfFieldsGet(SimpleTestCase): | class DataUploadMaxNumberOfFieldsGet(SimpleTestCase): | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user