Skip to content

fix(metadata): reject malformed Description-Content-Type values - #1329

Merged
henryiii merged 3 commits into
pypa:mainfrom
henryiii:desc-content-type-validation
Jul 11, 2026
Merged

henryiii merged 3 commits into
pypa:mainfrom
henryiii:desc-content-type-validation

Conversation

@henryiii

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Malformed Description-Content-Type values could leak a bare IndexError from the email header parser (e.g. text/plain; x*) or be silently accepted despite header defects (e.g. duplicated parameters). Raise InvalidMetadata for both, with a message that names the actual problem rather than claiming the content type is not one of the allowed values.

Split out of #1268 (part of #1239); validation tightening by @r266-tech, error-message wording per review.

henryiii and others added 2 commits July 11, 2026 00:08
Surface email-parser exceptions and header defects for
Description-Content-Type as InvalidMetadata instead of leaking
IndexError (e.g. "text/plain; x*") or silently accepting
defective values.

Extracted from pypa#1268.

Co-authored-by: r266-tech <r266-tech@users.noreply.github.com>
Assisted-by: ClaudeCode:claude-fable-5
The parse-error and header-defect paths reused the "must be one of"
message, which is wrong when the content type itself is valid but a
parameter is malformed. Say the value is not a valid content type
instead, including the defect text when there is one.

Assisted-by: ClaudeCode:claude-fable-5
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
@henryiii
henryiii merged commit 9d0ec47 into pypa:main Jul 11, 2026
69 checks passed
@henryiii
henryiii deleted the desc-content-type-validation branch July 11, 2026 12:59
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.

2 participants