Discussion:
Wrong MIME header encoding
Tomas Markauskas
2008-07-12 22:43:29 UTC
Permalink
Hello,

I noticed that subject headers in some emails sent with Zend_Mail
aren't shown correctly in Gmail. I think the implementation of RFC
1522 in Zend_Mail::_encodeHeader() is not correct. The RFC 1522 says
(http://tools.ietf.org/html/rfc1522#section-2), that if the string is
too long to fit into 75 characters, it can be written as multiple
encoded-words (and not encoded-texts), like this:

Subject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=
=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=

(Thats from RFC 1522 Section 8: http://tools.ietf.org/html/rfc1522#section-8)

But Zend_Mail uses just the simple Quoted-Printable encoding, which is
used in bodies etc. I still don't have any rigths to submit issues in
Jira, so I created a page with a simple fix for Zend_Mail/Zend_Mime:

http://code.tamole.net/zend_mail/

My two classes:

http://code.tamole.net/zend_mail/Fix_Mail.phps
http://code.tamole.net/zend_mail/Fix_Mime.phps

You can see the Zend_Mail result with an example string and the result
of my fixed implementation on the page.

As you can also see, the actual implementation has problems with
strings, containing lots of spaces or question marks, ie. not every
line is within required 75 characters. That's fixed there too now.

And a small note about the line endings: the RFC's use CRLF in all
possible places, but Zend_Mime declares it only as an "\n" character
(Zend_Mime::LINEEND). That doesn't seem to cause any problems (at
least not on Gmail), but maybe that should also get fixed.

I would really love to see those issues fixed sometime in the future.
Can someone post them to Jira or do I need write to Zend to request
rights for it?


Thanks,

Tomas Markauskas
Tobias Gies
2008-07-14 08:30:33 UTC
Permalink
Hi Tomas,

I noticed [...] not every
Post by Tomas Markauskas
line is within required 75 characters. That's fixed there too now.
I copied this text into a JIRA issue for you.
http://framework.zend.com/issues/browse/ZF-3641

I would really love to see those issues fixed sometime in the future.
Post by Tomas Markauskas
Can someone post them to Jira or do I need write to Zend to request
rights for it?
Yep, you should write to cla-C1q0ot2/***@public.gmane.org to request JIRA posting privileges,
IIRC.

Best regards
Tobias

Continue reading on narkive:
Loading...