diff -r 5a6b6e770365 -r 68c69c656a2c web/lib/Zend/Mime/Message.php --- a/web/lib/Zend/Mime/Message.php Thu May 07 15:10:09 2015 +0200 +++ b/web/lib/Zend/Mime/Message.php Thu May 07 15:16:02 2015 +0200 @@ -14,12 +14,11 @@ * * @category Zend * @package Zend_Mime - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Message.php 24593 2012-01-05 20:35:02Z matthew $ + * @version $Id$ */ - /** * Zend_Mime */ @@ -30,17 +29,26 @@ */ require_once 'Zend/Mime/Part.php'; - /** * @category Zend * @package Zend_Mime - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Mime_Message { + /** + * The Zend_Mime_Parts of the message + * + * @var array + */ + protected $_parts = array(); - protected $_parts = array(); + /** + * The Zend_Mime object for the message + * + * @var Zend_Mime|null + */ protected $_mime = null; /** @@ -134,7 +142,7 @@ */ public function generateMessage($EOL = Zend_Mime::LINEEND) { - if (! $this->isMultiPart()) { + if (!$this->isMultiPart()) { $body = array_shift($this->_parts); $body = $body->getContent($EOL); } else { @@ -146,9 +154,9 @@ foreach (array_keys($this->_parts) as $p) { $body .= $boundaryLine - . $this->getPartHeaders($p, $EOL) - . $EOL - . $this->getPartContent($p, $EOL); + . $this->getPartHeaders($p, $EOL) + . $EOL + . $this->getPartContent($p, $EOL); } $body .= $mime->mimeEnd($EOL); @@ -171,7 +179,8 @@ /** * Get the headers of a given part as a string * - * @param int $partnum + * @param int $partnum + * @param string $EOL * @return string */ public function getPartHeaders($partnum, $EOL = Zend_Mime::LINEEND) @@ -182,7 +191,8 @@ /** * Get the (encoded) content of a given part as a string * - * @param int $partnum + * @param int $partnum + * @param string $EOL * @return string */ public function getPartContent($partnum, $EOL = Zend_Mime::LINEEND) @@ -195,18 +205,19 @@ * * Parts consist of the header and the body of each MIME part. * - * @param string $body - * @param string $boundary + * @param string $body + * @param string $boundary + * @throws Zend_Exception * @return array */ protected static function _disassembleMime($body, $boundary) { $start = 0; - $res = array(); + $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); + $p = strpos($body, '--' . $boundary . "\n", $start); if ($p === false) { // no parts found! return array(); @@ -215,19 +226,21 @@ // position after first boundary line $start = $p + 3 + strlen($boundary); - while (($p = strpos($body, '--' . $boundary . "\n", $start)) !== false) { - $res[] = substr($body, $start, $p-$start); + 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) { + 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); + $res[] = substr($body, $start, $p - $start); + return $res; } @@ -235,12 +248,15 @@ * Decodes a MIME encoded string and returns a Zend_Mime_Message object with * all the MIME parts set according to the given string * - * @param string $message - * @param string $boundary - * @param string $EOL EOL string; defaults to {@link Zend_Mime::LINEEND} + * @param string $message + * @param string $boundary + * @param string $EOL EOL string; defaults to {@link Zend_Mime::LINEEND} + * @throws Zend_Exception * @return Zend_Mime_Message */ - public static function createFromMessage($message, $boundary, $EOL = Zend_Mime::LINEEND) + public static function createFromMessage( + $message, $boundary, $EOL = Zend_Mime::LINEEND + ) { require_once 'Zend/Mime/Decode.php'; $parts = Zend_Mime_Decode::splitMessageStruct($message, $boundary, $EOL); @@ -253,7 +269,7 @@ /** * @todo check for characterset and filename */ - switch(strtolower($key)) { + switch (strtolower($key)) { case 'content-type': $newPart->type = $value; break; @@ -261,7 +277,7 @@ $newPart->encoding = $value; break; case 'content-id': - $newPart->id = trim($value,'<>'); + $newPart->id = trim($value, '<>'); break; case 'content-disposition': $newPart->disposition = $value; @@ -276,11 +292,14 @@ $newPart->language = $value; break; default: - throw new Zend_Exception('Unknown header ignored for MimePart:' . $key); + throw new Zend_Exception( + 'Unknown header ignored for MimePart:' . $key + ); } } $res->addPart($newPart); } + return $res; } }