diff --git a/django/utils/http.py b/django/utils/http.py index 2950f3e695..068fc11e72 100644 --- a/django/utils/http.py +++ b/django/utils/http.py @@ -341,6 +341,21 @@ def parse_header_parameters(line, max_length=MAX_HEADER_LENGTH): if max_length is not None and len(line) > max_length: raise ValueError("Unable to parse header parameters (value too long).") + + if ";" not in line: + return line.lower().strip(), {} + + if '"' not in line and "*" not in line and "\\" not in line: + parts = line.split(";") + key = parts[0].lower().strip() + pdict = {} + for p in parts[1:]: + if "=" in p: + name, value = p.split("=", 1) + name = name.strip().lower() + if name: + pdict[name] = value.strip() + return key, pdict parts = _parseparam(";" + line) key = parts.__next__().lower()