Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/PhpImap/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ public function flattenParts(array $messageParts, array $flattenedParts = [], st
$part_parts = $part->parts;

if (self::PART_TYPE_TWO == $part->type) {
$flattenedParts = $this->flattenParts($part_parts, $flattenedParts, $prefix.$index.'.', 0, false);
$flattenedParts = $this->flattenParts($part_parts, $flattenedParts, $prefix.$index.'.', 1, false);
} elseif ($fullPrefix) {
$flattenedParts = $this->flattenParts($part_parts, $flattenedParts, $prefix.$index.'.');
} else {
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/MailboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,33 @@ public function testServerEncodingOnlyUseSupportedSettings(bool $bool, string $e
}
}

public function testFlattenPartsStartsRfc822SubPartsWithOne(): void
{
$plainTextPart = (object) [
'type' => TYPETEXT,
'subtype' => 'PLAIN',
];
$htmlPart = (object) [
'type' => TYPETEXT,
'subtype' => 'HTML',
];
$multipartAlternative = (object) [
'type' => TYPEMULTIPART,
'subtype' => 'ALTERNATIVE',
'parts' => [$plainTextPart, $htmlPart],
];
$rfc822Part = (object) [
'type' => Mailbox::PART_TYPE_TWO,
'subtype' => 'RFC822',
'parts' => [$multipartAlternative],
];

$flattenedParts = $this->getMailbox()->flattenParts([$rfc822Part]);

$this->assertSame(['1', '1.1', '1.2'], \array_keys($flattenedParts));
$this->assertArrayNotHasKey('1.0', $flattenedParts);
}

/**
* Test, that the IMAP search option has a default value
* 1 => SE_UID
Expand Down
Loading