Repository navigation
Fix MIME encoded-word decoding - #133407
Conversation
Decode RFC 2047 encoded-words token by token, honor case-insensitive encoding identifiers, and preserve the required whitespace behavior. Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
There was a problem hiding this comment.
🟡 Changes recommended
DecodeEncoding/DecodeHeaderValue can now throw on unknown charsets in scenarios that flow into public APIs (e.g., ContentType.Name) and tests don’t yet cover the new Q/q decode path.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates System.Net.Mail’s RFC 2047 “encoded-word” handling to better decode mixed ASCII + encoded-word header values (e.g., subjects and MIME parameter names), including case-insensitive encoding identifiers and improved whitespace behavior.
Changes:
- Reworks
MimeBasePart.DecodeHeaderValue/DecodeEncodingto tokenize by linear whitespace and decode encoded-words per token. - Adds regression tests for mixed ASCII + encoded-word decoding, plus ContentType
name=decoding. - Adds coverage for case-insensitive encoded-word encoding identifiers (tests currently only cover Base64).
File summaries
| File | Description |
|---|---|
| src/libraries/System.Net.Mail/src/System/Net/Mime/MimeBasePart.cs | Token-based RFC 2047 decoding and encoding detection logic for header values. |
| src/libraries/System.Net.Mail/tests/Unit/ByteEncodingTest.cs | Adds unit tests covering mixed ASCII/encoded-word decoding and identifier casing. |
| src/libraries/System.Net.Mail/tests/Unit/MessageTests/MessageHeaderBehaviorTest.cs | Adds subject regression test for mixed ASCII + encoded-word input. |
| src/libraries/System.Net.Mail/tests/Functional/ContentTypeTest.cs | Adds functional coverage for encoded-word decoding in ContentType.Name. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 4
- Review effort level: Lite
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The behavioral change is well-scoped, consistently applied across affected call sites, and backed by targeted unit/functional tests for the new decoding rules and edge cases.
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0 new
- Review effort level: Lite
Summary
B/Qencoding identifiers case-insensitivelyMailMessage.SubjectandContentType.NameTesting
System.Net.Mail.csprojbuild: 0 warnings, 0 errorsByteEncodingTest: 25 passedMessageHeaderBehaviorTest: 15 passedContentTypeTest: 30 passedNote
This pull request description was generated with GitHub Copilot.