Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'hotfix/mail-message-getsubject' of https://github.com/X…

…erkus/zf2 into release
  • Loading branch information...
commit d26640188fbafb62658f3b901b4360bf4ba9aa7a 2 parents d1146c8 + 45b4a39
@weierophinney weierophinney authored
View
2  library/Zend/Mail/Message.php
@@ -354,7 +354,7 @@ public function getSubject()
return null;
}
$header = $headers->get('subject');
- return $header->getFieldValue(Header\HeaderInterface::FORMAT_ENCODED);
+ return $header->getFieldValue();
}
/**
View
7 library/Zend/Mail/Transport/Sendmail.php
@@ -179,7 +179,12 @@ protected function prepareRecipients(Mail\Message $message)
*/
protected function prepareSubject(Mail\Message $message)
{
- return $message->getSubject();
+ $headers = $message->getHeaders();
+ if (!$headers->has('subject')) {
+ return null;
+ }
+ $header = $headers->get('subject');
+ return $header->getFieldValue(HeaderInterface::FORMAT_ENCODED);
}
/**
View
7 tests/ZendTest/Mail/MessageTest.php
@@ -602,6 +602,13 @@ public function testEncodingIsMutable()
$this->assertEquals('UTF-8', $this->message->getEncoding());
}
+ public function testMessageReturnsNonEncodedSubject()
+ {
+ $this->message->setSubject('This is a subject');
+ $this->message->setEncoding('UTF-8');
+ $this->assertEquals('This is a subject', $this->message->getSubject());
+ }
+
public function testSettingNonAsciiEncodingForcesMimeEncodingOfSomeHeaders()
{
$this->message->addTo('zf-devteam@zend.com', 'ZF DevTeam');
View
8 tests/ZendTest/Mail/Transport/SendmailTest.php
@@ -124,4 +124,12 @@ public function testLinesStartingWithFullStopsArePreparedProperlyForWindows()
$this->transport->send($message);
$this->assertContains("line.\n.. This", trim($this->message));
}
+
+ public function testAssertSubjectEncoded()
+ {
+ $message = $this->getMessage();
+ $message->setEncoding('UTF-8');
+ $this->transport->send($message);
+ $this->assertEquals('=?UTF-8?Q?Testing=20Zend\Mail\Transport\Sendmail?=', $this->subject);
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.