Only in lib.20060328/Zend/Mail: Message.php Only in lib.20060328/Zend/Mail: Read Only in lib.20060328/Zend/Mime: Decode.php diff -ur lib.orig/Zend/Mime/Message.php lib.20060328/Zend/Mime/Message.php --- lib.orig/Zend/Mime/Message.php 2006-02-17 00:01:14.000000000 +0100 +++ lib.20060328/Zend/Mime/Message.php 2006-03-28 19:02:30.000000000 +0200 @@ -28,6 +28,10 @@ */ require_once 'Zend/Mime/Part.php'; +/** + * Zend_Mime_Decode + */ +require_once 'Zend/Mime/Decode.php'; /** * @package Zend_Mime @@ -175,47 +179,6 @@ } /** - * explode mime multipart string into seperate parts - * the parts consist of the header and the body of the - * mime part. - * - * @param string $body - * @param string $boundary - * @return array - */ - protected function _disassembleMime($body, $boundary) - { - $start = 0; - $res = array(); - // find every mime part limiter and cut out the - // string before it. - // the part before the first boundary string is discarded: - $p = strpos($body, '--'.$boundary."\n", $start); - if ($p === false) { - // no parts found! - return array(); - } - - // position after first boundary line - $start = $p + 3 + strlen($boundary); - - while (($p = strpos($body, '--' . $boundary . "\n", $start)) !== false) { - $res[] = substr($body, $start, $p-$start); - $start = $p + 3 + strlen($boundary); - } - - // no more parts, find end boundary - $p = strpos($body, '--' . $boundary . '--', $start); - if ($p===false) { - throw new Zend_Exception('Not a valid Mime Message: End Missing'); - } - - // the remaining part also needs to be parsed: - $res[] = substr($body, $start, $p-$start); - return $res; - } - - /** * decodes a mime encoded String and returns a MimeMessage * object with all the mime parts set according to the given * string @@ -226,62 +189,30 @@ */ public static function createFromMessage($message, $boundary) { - $partsStr = self::_disassembleMime($message, $boundary); - if (count($partsStr)<=0) return null; - + $parts = Zend_Mime_Decode::splitMessageStruct($message, $boundary); + $res = new Zend_Mime_Message(); - foreach($partsStr as $part) { - // separate header and body - $header = true; // expecting header lines first - $headersfound = array(); - $body = ''; - $lastheader = ''; - $lines = explode("\n", $part); - - // read line by line - foreach ($lines as $line) { - $line = trim($line); - if ($header) { - if ($line == '') { - $header=false; - } elseif (strpos($line, ':')) { - list($key, $value) = explode(':', $line, 2); - $headersfound[trim($key)] = trim($value); - $lastheader = trim($key); - } else { - if ($lastheader!='') { - $headersfound[$lastheader] .= ' '.trim($line); - } else { - // headers do not start with an ordinary header line? - // then assume no headers at all - $header = false; - } - } - } else { - $body .= $line . Zend_Mime::LINEEND; - } - } - + foreach ($parts as $part) { // now we build a new MimePart for the current Message Part: - $newPart = new Zend_Mime_Part($body); - foreach ($headersfound as $key => $value) { + $newPart = new Zend_Mime_Part($part['body']); + foreach ($part['header'] as $key => $value) { /** * @todo check for characterset and filename */ switch($key) { - case 'Content-Type': + case 'content-type': $newPart->type = $value; break; - case 'Content-Transfer-Encoding': + case 'content-transfer-encoding': $newPart->encoding = $value; break; - case 'Content-ID': + case 'content-id': $newPart->id = trim($value,'<>'); break; - case 'Content-Disposition': + case 'content-disposition': $newPart->disposition = $value; break; - case 'Content-Description': + case 'content-description': $newPart->description = $value; break; default: