One function
_parse_content_type_header in psf/requests
The author described this change as “Fix malformed value parsing for Content-Type (#7309)”. It counts as a record because the check below fails on the code as it stood at bc7dd0fc4 and passes on f0198e6df, with nothing else changed between the two runs.
Projectpsf/requests
Fix saved2026-03-30
Sharing licenceApache-2.0 · LICENSE
Change size+6 −9
What the code was meant to do, written into the code itself as a docstring
Returns content type and parameters from given header :param header: string :return: tuple containing content type and dictionary of parameters
The change
| 1 | 1 | def _parse_content_type_header(header): | |
| 2 | - | """Returns content type and parameters from given header | |
| 2 | + | """Returns content type and parameters from given header. | |
| 3 | 3 | ||
| 4 | 4 | :param header: string | |
| 5 | 5 | :return: tuple containing content type and dictionary of | |
| 6 | - | parameters | |
| 6 | + | parameters. | |
| 7 | 7 | """ | |
| 8 | 8 | ||
| 9 | 9 | tokens = header.split(";") | |
| 10 | 10 | content_type, params = tokens[0].strip(), tokens[1:] | |
| 11 | 11 | params_dict = {} | |
| 12 | - | items_to_strip = "\"' " | |
| 12 | + | strip_chars = "\"' " | |
| 13 | 13 | ||
| 14 | 14 | for param in params: | |
| 15 | 15 | param = param.strip() | |
| 16 | - | if param: | |
| 17 | - | key, value = param, True | |
| 18 | - | index_of_equals = param.find("=") | |
| 19 | - | if index_of_equals != -1: | |
| 20 | - | key = param[:index_of_equals].strip(items_to_strip) | |
| 21 | - | value = param[index_of_equals + 1 :].strip(items_to_strip) | |
| 16 | + | if param and (idx := param.find("=")) != -1: | |
| 17 | + | key = param[:idx].strip(strip_chars) | |
| 18 | + | value = param[idx + 1 :].strip(strip_chars) | |
| 22 | 19 | params_dict[key.lower()] = value | |
| 23 | 20 | return content_type, params_dict |
The check that tells the two apart
fail→pass·tests/test_utils.py::test__parse_content_type_header[multipart/form-data;
Check file tests/test_utils.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itbc7dd0fc4d56e808bcdd85ac2d797b3107c89259
Broken version dated2026-03-30
Modulerequests.utils
Units changed_parse_content_type_header
Fingerprint6e4e66296f7f4e3a
Checked2026-08-17 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in psf/requests
- 2026-02-13get_netrc_auth