Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Duplicate
-
Affects Version/s: 1.5.2
-
Fix Version/s: None
-
Component/s: Zend_Mail
-
Labels:None
Description
When using Zend_Mail with utf-8 encoding and hebrew characters, the subject is incorrectly encoded causing artifacts to appear. I've tracked this to the protected method _encodeHeader(), line 393 in Zend_Mail:
protected function _encodeHeader($value) { if (Zend_Mime::isPrintable($value)) { return $value; } else { $quotedValue = Zend_Mime::encodeQuotedPrintable($value); $quotedValue = str_replace(array('?', ' '), array('=3F', '=20'), $quotedValue); return '=?' . $this->_charset . '?Q?' . $quotedValue . '?='; } }
Replacing the quoting method to encodeBase64() of Zend_Mime seems to fix the issue. Meaning:
protected function _encodeHeader($value) { if (Zend_Mime::isPrintable($value)) { return $value; } else { return '=?' . $this->_charset . '?B?' . Zend_Mime::encodeBase64($value) . '?='; } }
Will return a correctly formatted utf-8 subject. I'm not an expert on Mime so I can't tell if this is the best solution. However it should be fixed to correctly format utf-8 subjects
That issue is also present in 1.5.3 and 1.6.0 rc1.
Here is another fix without using the base64 encoding.
It's not perfect either but it corrects the issue.