Decode RFC 2231 MIME parameters#170
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes RFC 2231 MIME parameter handling so attachment filenames (and content-type name parameters) are correctly reconstructed from continuation segments and decoded from extended/percent-encoded forms when parsing IMAP BODYSTRUCTURE.
Changes:
- Added
MimeParameterParserto normalize MIME parameters (RFC 2231 continuations + extended decoding). - Wired normalized parameter parsing into
BodyStructurePart,BodyStructureCollection, andContentDisposition. - Added unit tests covering continuations, extended parameters, charset conversion, and compatibility decoding.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/Support/MimeParameterParserTest.php | Adds focused unit tests for RFC 2231 continuations/extended decoding and compatibility cases. |
| tests/Unit/BodyStructureTest.php | Adds integration-style tests ensuring BODYSTRUCTURE parsing yields correct filenames/parameters. |
| src/Support/MimeParameterParser.php | Introduces central MIME parameter normalization via MailMimeParser. |
| src/ContentDisposition.php | Uses MimeParameterParser so disposition parameters (e.g., filename*0, filename*1) are reconstructed. |
| src/BodyStructurePart.php | Uses MimeParameterParser for part parameters and relies on normalized name for filenames when no disposition. |
| src/BodyStructureCollection.php | Uses MimeParameterParser for multipart parameters (e.g., boundary) and normalized names. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #169
This PR fixes attachment filenames that are split across multiple RFC 2231 MIME parameters in IMAP
BODYSTRUCTUREresponses.Some IMAP servers return attachment filenames as numbered parameters:
ImapEngine previously looked only for an exact
filenameornameparameter. As a result, lazy-loaded attachments could have anullfilename even though the complete filename was present in the response.Extended parameters containing percent-encoded values and charset information were also not being decoded.