summaryrefslogtreecommitdiff
path: root/django/http/multipartparser.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2019-03-01 13:47:09 -0500
committerTim Graham <timograham@gmail.com>2019-03-02 09:19:05 -0500
commit8ec7ded3706fe66bf307ed339eb852d73f6d10d0 (patch)
treeb2ad9b885302717a70e3a9fb0d7d751783d4d637 /django/http/multipartparser.py
parent2ed2acf872b87d1149da98ceeb96997f23258e83 (diff)
downloaddjango-8ec7ded3706fe66bf307ed339eb852d73f6d10d0.tar.gz
Refs #30227 -- Added helpful message for non-ASCII Content-Type in mulitpart request.
Diffstat (limited to 'django/http/multipartparser.py')
-rw-r--r--django/http/multipartparser.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py
index 526e161ae4..07a1d676ee 100644
--- a/django/http/multipartparser.py
+++ b/django/http/multipartparser.py
@@ -67,7 +67,10 @@ class MultiPartParser:
raise MultiPartParserError('Invalid Content-Type: %s' % content_type)
# Parse the header to get the boundary to split the parts.
- ctypes, opts = parse_header(content_type.encode('ascii'))
+ try:
+ ctypes, opts = parse_header(content_type.encode('ascii'))
+ except UnicodeEncodeError:
+ raise MultiPartParserError('Invalid non-ASCII Content-Type in multipart: %s' % force_str(content_type))
boundary = opts.get('boundary')
if not boundary or not cgi.valid_boundary(boundary):
raise MultiPartParserError('Invalid boundary in multipart: %s' % force_str(boundary))