Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Mail\Message::getSubject() should return value the way it was set #2334

Merged
merged 2 commits into from Sep 13, 2012

Conversation

Projects
None yet
2 participants
Member

Xerkus commented Sep 10, 2012

Message return subject in encoded form which is quite unexpected behaviour for end user

$message->setSubject('Subject');
$message->setEncoding('UTF-8');
$message->getSubject(); // Subject
//before this PR:
$message->getSubject(); // =?UTF-8?Q?Subject?=

Transport should retrieve encoded Subject header value from headers and not directly from message object.

@weierophinney weierophinney commented on the diff Sep 13, 2012

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);
@weierophinney

weierophinney Sep 13, 2012

Owner

Should this also be done for SMTP and/or File transports? or is it an issue only for the Sendmail transport?

@Xerkus

Xerkus Sep 13, 2012

Member

Message::getSubject() was used only in sendmail.
I will check if getters for other properties proxied to Headers are used in transports and replace them with direct access too.

@ghost ghost assigned weierophinney Sep 13, 2012

@weierophinney weierophinney merged commit 45b4a39 into zendframework:master Sep 13, 2012

1 check passed

default The Travis build passed
Details
Owner

weierophinney commented Sep 13, 2012

Merged to master and release branches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment