FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Accept Unicode str values in parse_options_header by gyanu2507 · Pull Request #321 · Kludex/python-multipart · GitHub

Accept Unicode str values in parse_options_header - #321

Open
gyanu2507 wants to merge 2 commits into
Kludex:mainfrom
gyanu2507:fix/parse-options-header-unicode
Open

Accept Unicode str values in parse_options_header#321
gyanu2507 wants to merge 2 commits into
Kludex:mainfrom
gyanu2507:fix/parse-options-header-unicode

Conversation

gyanu2507 commented Aug 22, 2026
edited by cubic-dev-ai Bot
Loading

Copy link
Copy Markdown

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

The function already takes str, but encoding as latin-1 raised UnicodeEncodeError for filenames like 中文.doc. Fall back to UTF-8 when latin-1 cannot represent the value.

codspeed-hq Bot commented Aug 22, 2026
edited
Loading

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 5 skipped benchmarks1


Comparing gyanu2507:fix/parse-options-header-unicode (4b35e58) with main (d9cb4c6)

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

No issues found across 3 files

You’re at about 97% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Re-trigger cubic

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify or handle non-Latin-1 str input in parse_options_header

1 participant


Back | FazBrowse Home | New Git URL