ZF-3115: Zend_Mime_Decode::splitHeaderField doesn't work for some headers


It's not a normal bug, but rather problem with client application which sends bad mail headers (with additional spaces).

The problem is in class Zend_Mime_Decode, in method splitHeaderField, which returns empty string for header key, which is formated with additional spaces. This bug affect Zend_Mail_Part class so I cannot get message parts.

Sample headers (x-mailer: Microsoft Office Outlook, Build 11.0.5510) - additional space after "boundary":

{{content-type: multipart/mixed; boundary ="_NextPart_000_3798.1087"}}

Possible solution :

--- Decode.php  2008-04-15 21:24:18.606926208 +0200
+++ Decode-changed.php       2008-04-15 21:24:23.654158912 +0200
@@ -199,6 +199,7 @@

         if ($wantedPart) {
             foreach ($matches[1] as $key => $name) {
+                $name = trim($name);
                 if (strcasecmp($name, $wantedPart)) {

or modify regular expression in preg_match_all


Please evaluate and categorize/assign as necessary.

The space after the parameter name doesn't seem to be a valid character and I couldn't find a mail doing that (maybe it was spam?). But as it's invalid we can safely ignore it and it's now eaten by the regex.

Updating for the 1.6.0 release.