diff options
Diffstat (limited to 'django/utils/http.py')
| -rw-r--r-- | django/utils/http.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/utils/http.py b/django/utils/http.py index f72f54e958..f6cce96206 100644 --- a/django/utils/http.py +++ b/django/utils/http.py @@ -366,7 +366,11 @@ def parse_header_parameters(line, max_length=MAX_HEADER_LENGTH): value = value.replace("\\\\", "\\").replace('\\"', '"') if has_encoding: encoding, lang, value = value.split("'") - value = unquote(value, encoding=encoding) + try: + value = unquote(value, encoding=encoding) + except (LookupError, UnicodeDecodeError): + msg = f"Invalid encoding {encoding!r} for RFC 2231 param." + raise ValueError(msg) pdict[name] = value return key, pdict |
