diff options
| author | Dinesh <dineshthumma15@gmail.com> | 2026-03-21 22:51:11 +0530 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-04-22 14:25:08 -0400 |
| commit | dc467fdc3b5744cec71fab876c23a14013e2510b (patch) | |
| tree | 5702150cc3838f3e97af78599614f257ea950cf0 /django/http/request.py | |
| parent | e1bdebc84ee7cacd40b820e862fd504054619403 (diff) | |
Fixed #36991 -- Raised BadRequest for invalid encodings in Content-Type headers.
Diffstat (limited to 'django/http/request.py')
| -rw-r--r-- | django/http/request.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/django/http/request.py b/django/http/request.py index f871ea15e8..44bf09450b 100644 --- a/django/http/request.py +++ b/django/http/request.py @@ -155,9 +155,12 @@ class HttpRequest: def _set_content_type_params(self, meta): """Set content_type, content_params, and encoding.""" - self.content_type, self.content_params = parse_header_parameters( - meta.get("CONTENT_TYPE", "") - ) + try: + self.content_type, self.content_params = parse_header_parameters( + meta.get("CONTENT_TYPE", "") + ) + except ValueError as exc: + raise BadRequest("Invalid Content-Type header.") from exc if "charset" in self.content_params: try: codecs.lookup(self.content_params["charset"]) |
