Normalize content type when parsing options headers
Merged
ED
1mo ago+10+10+01234567890123456789-7-7-0123456789
Summary
This normalizes the content type returned by parse_options_header() when the header includes parameters.
Previously, content types without parameters were lowercased, but content types with parameters preserved their original casing. That caused a valid header like:
Content-Type: Multipart/Form-Data; boundary=abc
to be rejected by create_form_parser(), because FormParser compares against lowercase media types such as multipart/form-data.
Media types are case-insensitive, so this patch lowercases and strips the parsed content type consistently.
Changes
- Normalize content type returned from
email.message.Message.get_params() - Add regression coverage for
parse_options_header() - Add regression coverage for
create_form_parser()with mixed-case multipart content type
Verification
uv run pytest tests/test_multipart.py
uv run ruff check python_multipart/multipart.py tests/test_multipart.py
Thank you for maintaining this project. Kindly review when you have time, and please let me know if any changes are needed. Happy to update the patch.