Fix: IMAP Header Array Handling, Multipart Boundary Fallback, and Robust Date Parsing#152
Open
fsdultra wants to merge 3 commits intoZ-Hub:developfrom
Open
Fix: IMAP Header Array Handling, Multipart Boundary Fallback, and Robust Date Parsing#152fsdultra wants to merge 3 commits intoZ-Hub:developfrom
fsdultra wants to merge 3 commits intoZ-Hub:developfrom
Conversation
Added support for 'Y-m-d\THis' format (e.g., 2025-03-27T130000). Also ensures the method returns `false` explicitly when all parsing attempts fail and an error is logged.
Previously, if a multipart content-type (e.g. multipart/mixed) was missing a boundary parameter, mimeDecode would return an error and skip processing the part. This commit changes the behavior to fallback to treating the content as plain text when no boundary is found. It ensures the body is included and decoded if requested, preventing silent data loss and improving compatibility with malformed messages
- Adjusted handling of "date", "subject", and "from" headers in BackendIMAP to support array values (take first element when needed). - Ensured `Mail_RFC822` uses the first element of the address array to avoid invalid parsing. - Prevents potential issues with multi-valued headers causing type mismatches or incorrect field extraction.
|
tks. |
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.
Released under the GNU Affero General Public License (AGPL), version 3
Released under the GNU Affero General Public License (AGPL), version 3 and Trademark Additional Terms.
What does this implement/fix?
This pull request addresses multiple issues related to header handling, multipart messages, and date parsing in the IMAP backend.
✅ Fix: Handle header fields as arrays in IMAP backend and address parser
"date","subject", and"from"headers inBackendIMAPto support array values (safely fallback to the first element when necessary).Mail_RFC822address parser uses the first element of the address array to avoid invalid parsing.✅ Fix: Handle missing
boundaryin multipart messagesmimeDecodewould fail when amultipart/*message lacked aboundaryparameter.✅ Improve date parsing in
TimezoneUtil::MakeUTCDate'Y-m-d\THis'(e.g.,2025-03-27T130000).falseexplicitly when all parsing attempts fail and logs an error to assist with debugging.Does this close any currently open issues?
Any relevant logs, error output, etc?
Error 1 – Header as array:
[FATAL] [xxx@domain.com] Uncaught TypeError: strlen(): Argument #1 ($str) must be of type string, array given
in /usr/local/lib/z-push/lib/core/streamer.php:309
Error 2 – Invalid DateTime parsing:
[FATAL] [xxx@domain.com] Uncaught TypeError: date_timestamp_get(): Argument #1 ($object) must be of type DateTimeInterface, false given
in /usr/local/lib/z-push/lib/utils/timezoneutil.php:1335
Where has this been tested?
Sample messages (for reproduction):
📎 bugs.zip
Test Environment:
Client: