Accept Unicode str values in parse_options_header

GY
2mo ago
+23-3

parse_options_header already takes str | bytes | None, but a str with characters outside Latin-1 raises UnicodeEncodeError. That's the filename case people actually hit:

parse_options_header('form-data; name="upload"; filename="中文.doc"')

Bytes (the WSGI path) were already fine. For str this encodes as Latin-1 when it fits and falls back to UTF-8 otherwise, so the public API matches its type hint.

The issue asked which of the three options you wanted. I went with supporting Unicode str rather than a clearer error, because the signature already accepts str and that's what callers pass for filenames. Happy to switch to a dedicated error if you'd rather keep the Latin-1-only contract explicit.

Fixes #319