ZF-4819: long mail subject bad encoding
Description
When setting a long subject with accent it break the mail
it seems the probleme come from the line return in case of subject encode in quoted printable format.
The encoding is done like this : Subject: Un exemple de texte =?ISO-8859-1?Q?tr=E8s_long_avec_des_= accents_qui_posent_probl=E8me?=
And according to rfc it must be done like this : Subject: Un exemple de texte =?ISO-8859-1?Q?tr=E8s_long_avec_des_?= =?ISO-8859-1?Q?accents_qui_posent_probl=E8me?=
Nicolas PERIDONT
Comments
Posted by Marco Frank (melchior) on 2008-11-20T03:01:42.000+0000
can confirm this.
same problem.
Posted by Denes Szabo (denes.szabo) on 2008-12-06T14:44:51.000+0000
This is not a big error only a small easy amendable mistake.
The Zend_Mail encodes the subject in the _encodeHeader() function with this:
$quotedValue = Zend_Mime::encodeQuotedPrintable($value); (398. line in the 1.7)
Zend_Mime::encodeQuotedPrintable() uses 74 for the default line length (Zend_Mime::LINELENGTH = 74)
So, this is the problem: Zend_Mime encodes the value (subject) but it is too long for one line. Zend_Mime splits a line.
If you changes the _encodeHeader() to encodes the header vales with $quotedValue = Zend_Mime::encodeQuotedPrintable($value, 200); it will be ok.
So there are the missing length parameter.
It would be nice a a configurable length parameter in the Zend_Mail, maybe...
I am a hungarian. We uses a strange chars like őúőéáűüöóí... So this chars encoded line will be long... 74 char is not enough to us :D
Posted by Marco Frank (melchior) on 2008-12-07T02:56:24.000+0000
hi,
in the meanwhile I found this function to override the original one in Zend_Mail:
protected function encodeHeader($value) { if (Zend_Mime::isPrintable($value)) { return $value; } else { $quotedValue = Zend_Mime::encodeQuotedPrintable($value); $quotedValue = str_replace(array('?', ' ', '', '=' . Zend_Mime::LINEEND), array('=3F', '=20', '=5F', ''), $quotedValue); return '=?' . $this->_charset . '?Q?' . $quotedValue . '?='; } }
by using this all works fine. No more interrupted subjects in mails.
regards, marco
Posted by old of Satoru Yoshida (yoshida@zend.co.jp) on 2009-01-02T23:25:32.000+0000
I think it duplicates ZF-1688