Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/4931' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Message.php
Expand Up @@ -224,6 +224,7 @@ public static function createFromMessage($message, $boundary, $EOL = Mime::LINEE
foreach ($parts as $part) {
// now we build a new MimePart for the current Message Part:
$newPart = new Part($part['body']);

foreach ($part['header'] as $header) {
/** @var \Zend\Mail\Header\HeaderInterface $header */
/**
Expand Down Expand Up @@ -255,7 +256,8 @@ public static function createFromMessage($message, $boundary, $EOL = Mime::LINEE
$newPart->language = $fieldValue;
break;
default:
throw new Exception\RuntimeException('Unknown header ignored for MimePart:' . $fieldName);
// Ignore unknown header
break;
}
}
$res->addPart($newPart);
Expand Down
30 changes: 30 additions & 0 deletions test/MimeTest.php
Expand Up @@ -135,6 +135,36 @@ public static function dataTestEncodeMailHeaderBase64()
);
}

public function testFromMessageMultiPart()
{
$message = Mime\Message::createFromMessage(
'--089e0141a1902f83ee04e0a07b7a'."\r\n"
.'Content-Type: multipart/alternative; boundary=089e0141a1902f83e904e0a07b78'."\r\n"
."\r\n"
.'--089e0141a1902f83e904e0a07b78'."\r\n"
.'Content-Type: text/plain; charset=UTF-8'."\r\n"
."\r\n"
.'Foo'."\r\n"
."\r\n"
.'--089e0141a1902f83e904e0a07b78'."\r\n"
.'Content-Type: text/html; charset=UTF-8'."\r\n"
."\r\n"
.'<p>Foo</p>'."\r\n"
."\r\n"
.'--089e0141a1902f83e904e0a07b78--'."\r\n"
.'--089e0141a1902f83ee04e0a07b7a'."\r\n"
.'Content-Type: image/png; name="1.png"'."\r\n"
.'Content-Disposition: attachment; filename="1.png"'."\r\n"
.'Content-Transfer-Encoding: base64'."\r\n"
.'X-Attachment-Id: barquux'."\r\n"
."\r\n"
.'Zm9vCg=='."\r\n"
.'--089e0141a1902f83ee04e0a07b7a--',
'089e0141a1902f83ee04e0a07b7a'
);
$this->assertSame(2, count($message->getParts()));
}

/**
* @group ZF-1688
*/
Expand Down

0 comments on commit 924558c

Please sign in to comment.