summaryrefslogtreecommitdiff
path: root/django/http
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-10-11 23:20:25 +0200
committerClaude Paroz <claude@2xlibre.net>2012-11-17 17:25:21 +0100
commit2a67374b51c5705d5c64a5d7117ad8552e98b4bb (patch)
treecbe0fd10c4d9a4b9d78d904c2f2d16110350ba68 /django/http
parent9e7723f851dc6e4d5eea96ab808e1a4cdd4eabd7 (diff)
Fixed #19036 -- Fixed base64 uploads decoding
Thanks anthony at adsorbtion.org for the report, and johannesl for bringing the patch up-to-date.
Diffstat (limited to 'django/http')
-rw-r--r--django/http/multipartparser.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py
index 9413a1eabb..edf98f6e49 100644
--- a/django/http/multipartparser.py
+++ b/django/http/multipartparser.py
@@ -199,6 +199,12 @@ class MultiPartParser(object):
for chunk in field_stream:
if transfer_encoding == 'base64':
# We only special-case base64 transfer encoding
+ # We should always read base64 streams by multiple of 4
+ over_bytes = len(chunk) % 4
+ if over_bytes:
+ over_chunk = field_stream.read(4 - over_bytes)
+ chunk += over_chunk
+
try:
chunk = base64.b64decode(chunk)
except Exception as e: