Skip to content

Commit 1602b3d

Browse files
author
Christian Bartels
committed
Process root element of embedded emails
An email with an embedded email can have the following structure: 1: "text/plain" 2: "message/rfc822" 2: "multipart/mixed" 2.1: "text/plain" 2.2: "application/octet-stream" 2.3, "application/octet-stream" Before this fix this structure was parsed as 1: "text/plain" 2: "message/rfc822" 2.1: "multipart/mixed" 2.1.1: "text/plain" 2.1.2: "application/octet-stream" 2.1.3, "application/octet-stream" Hence, downloading attachments was not possible due to wrong part identifiers resolves tedious#188, tedious#43
1 parent 9a1b0eb commit 1602b3d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/Fetch/Message.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,15 +562,21 @@ protected function processStructure($structure, $partIdentifier = null)
562562
}
563563
}
564564

565-
if (isset($structure->parts)) { // multipart: iterate through each part
565+
if (! empty($structure->parts)) {
566566

567-
foreach ($structure->parts as $partIndex => $part) {
568-
$partId = $partIndex + 1;
567+
if (isset($structure->subtype) && strtolower($structure->subtype) === 'rfc822') {
568+
// rfc822: The root part is processed with the current part identifier
569+
$this->processStructure($structure->parts[0], $partIdentifier);
570+
} else {
571+
// multipart: iterate through each part
572+
foreach ($structure->parts as $partIndex => $part) {
573+
$partId = $partIndex + 1;
569574

570-
if (isset($partIdentifier))
571-
$partId = $partIdentifier . '.' . $partId;
575+
if (isset($partIdentifier))
576+
$partId = $partIdentifier . '.' . $partId;
572577

573-
$this->processStructure($part, $partId);
578+
$this->processStructure($part, $partId);
579+
}
574580
}
575581
}
576582
}

0 commit comments

Comments
 (0)