﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37538	Malformed Accept header crashes HttpRequest.accepts()/get_preferred_type() (HTTP 500) since CVE-2026-84429 fix	Kingsley	Kingsley	"Since the CVE-2026-84429 fix (5.2.18 / 6.0.9 / 6.1.2), which made `parse_header_parameters()` use `email.message.Message`, short Accept media ranges with RFC 2231 extended parameters raise `ValueError` (or its subclass `UnicodeError`). `HttpRequest.accepted_types` calls `MediaType(token)` on client-supplied tokens without handling `ValueError`, so `accepts()`, `get_preferred_type()` and `accepted_type()` crash with a 500.

This affects the built-in `set_language` view when no `next` parameter is given:

{{{
GET /i18n/setlang/ HTTP/1.1
Host: example.com
Accept: text/html; a*=idna''v
}}}

 * 6.1.3, 6.0.10, 5.2.19, main: 500 (`UnicodeError: Unsupported error handling replace`)
 * 6.1.1, 6.0.8, 5.2.17: 204

Other values that crash on the affected versions: `text/html; a*=x-no-such-charset''v` (`ValueError: Invalid encoding`), `text/html; a*=undefined''v` (`UnicodeError`), and `text/html; a*` + 4301 digits + `=v` (int digit limit). Percent-encoded variants such as `a*=undefined''%41` already crashed before the change. The CVE fix widened what triggers it.

Other callers of `parse_header_parameters()` already handle `ValueError` (`_set_content_type_params()`, the multipart parser), and `MediaType.quality` already ignores invalid `q` values. A possible fix is to skip media ranges in `accepted_types` that fail to parse. I have a patch with a regression test in `requests_tests.test_accept_header` and can open a PR.

Related but distinct: #37445 (Content-Type raising during request construction). Its PR doesn't touch `accepted_types`.

Tested with Python 3.12.10.

AI disclosure: Claude Code (Claude Opus 5.5) was used to investigate the code, write and run the reproduction scripts across Django versions, search Trac, and draft this text. I reviewed and re-ran the reproduction myself before filing."	Bug	assigned	HTTP handling	6.1	Release blocker				Unreviewed	1	0	0	0	0	0
