summaryrefslogtreecommitdiff
path: root/django/http/multipartparser.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/http/multipartparser.py')
-rw-r--r--django/http/multipartparser.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py
index 58b8546be7..5edf024b31 100644
--- a/django/http/multipartparser.py
+++ b/django/http/multipartparser.py
@@ -304,15 +304,18 @@ class MultiPartParser:
# We should always decode base64 chunks by
# multiple of 4, ignoring whitespace.
- stripped_chunk = b"".join(chunk.split())
+ stripped_parts = [b"".join(chunk.split())]
+ stripped_length = len(stripped_parts[0])
- remaining = len(stripped_chunk) % 4
- while remaining != 0:
- over_chunk = field_stream.read(4 - remaining)
+ while stripped_length % 4 != 0:
+ over_chunk = field_stream.read(self._chunk_size)
if not over_chunk:
break
- stripped_chunk += b"".join(over_chunk.split())
- remaining = len(stripped_chunk) % 4
+ over_stripped = b"".join(over_chunk.split())
+ stripped_parts.append(over_stripped)
+ stripped_length += len(over_stripped)
+
+ stripped_chunk = b"".join(stripped_parts)
try:
chunk = base64.b64decode(stripped_chunk)