Only trim spaces and tabs around header parameters
Merged
KL
11d ago+28+28+01234567890123456789-3-3-0123456789
parse_options_header trimmed parameter names and values with strip(), rstrip() and lstrip() without arguments. Those remove all Unicode whitespace, and because the header is decoded as latin-1, the bytes 0xA0 and 0x85 count as whitespace too. Whitespace around a header parameter is only a space or a tab (RFC 9110 §5.6.3).
| Header | Before | After |
|---|---|---|
form-data; name=voil\xc3\xa0 | name is voil\xc3 | name is voil\xc3\xa0 |
form-data; name="a";\xa0filename="a.txt" | Has filename | \xa0filename isn't filename, so the part is a field |
multipart/form-data; boundary=XX\xa0 | Boundary is XX | Boundary is XX\xa0 |
Spaces and tabs are still trimmed, and quoted values are unchanged.
AI Disclaimer
This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.