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

Commit

Permalink
Merge branch 'hotfix/7503'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed May 11, 2015
3 parents a005f92 + f97097e + edf53ed commit ea143e3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public function setBody($body)
$parts = $this->body->getParts();
if (!empty($parts)) {
$part = array_shift($parts);
$headers->addHeaders($part->getHeadersArray());
$headers->addHeaders($part->getHeadersArray("\r\n"));
}
return $this;
}
Expand Down
35 changes: 35 additions & 0 deletions test/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,4 +745,39 @@ public function testDetectsCRLFInjectionViaSubject()
$this->assertContains('example', $serializedHeaders);
$this->assertNotContains("\r\n<html>", $serializedHeaders);
}

public function testHeaderUnfoldingWorksAsExpectedForMultipartMessages()
{
$text = new MimePart('Test content');
$text->type = Mime::TYPE_TEXT;
$text->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
$text->disposition = Mime::DISPOSITION_INLINE;
$text->charset = 'UTF-8';

$html = new MimePart('<b>Test content</b>');
$html->type = Mime::TYPE_HTML;
$html->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
$html->disposition = Mime::DISPOSITION_INLINE;
$html->charset = 'UTF-8';

$multipartContent = new MimeMessage();
$multipartContent->addPart($text);
$multipartContent->addPart($html);

$multipartPart = new MimePart($multipartContent->generateMessage());
$multipartPart->charset = 'UTF-8';
$multipartPart->type = 'multipart/alternative';
$multipartPart->boundary = $multipartContent->getMime()->boundary();

$message = new MimeMessage();
$message->addPart($multipartPart);

$this->message->getHeaders()->addHeaderLine('Content-Transfer-Encoding', Mime::ENCODING_QUOTEDPRINTABLE);
$this->message->setBody($message);

$contentType = $this->message->getHeaders()->get('Content-Type');
$this->assertInstanceOf('Zend\Mail\Header\ContentType', $contentType);
$this->assertContains('multipart/alternative', $contentType->getFieldValue());
$this->assertContains($multipartContent->getMime()->boundary(), $contentType->getFieldValue());
}
}

0 comments on commit ea143e3

Please sign in to comment.