Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2 into feat…
Browse files Browse the repository at this point in the history
…ure/console
  • Loading branch information
Thinkscape committed Jul 15, 2012
6 parents 8cd9c64 + 757d24d + 02e6999 + edaf480 + 1ede9ce + 8630680 commit 36c4a42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 16 additions & 4 deletions src/Decode.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Zend\Mime;

use Zend\Mail\Headers;
use Zend\Stdlib\ErrorHandler;

/**
* @category Zend
Expand Down Expand Up @@ -100,9 +101,10 @@ public static function splitMessageStruct($message, $boundary, $EOL = Mime::LINE
* @param Headers $headers output param, headers container
* @param string $body output param, content of message
* @param string $EOL EOL string; defaults to {@link Zend_Mime::LINEEND}
* @param boolean $strict enable strict mode for parsing message
* @return null
*/
public static function splitMessage($message, &$headers, &$body, $EOL = Mime::LINEEND)
public static function splitMessage($message, &$headers, &$body, $EOL = Mime::LINEEND, $strict = false)
{
if ($message instanceof Headers) {
$message = $message->toString();
Expand All @@ -116,19 +118,29 @@ public static function splitMessage($message, &$headers, &$body, $EOL = Mime::LI
return;
}

// see @ZF2-372, pops the first line off a message if it doesn't contain a header
if (!$strict) {
$parts = explode(': ', $firstline, 2);
if (count($parts) != 2) {
$message = substr($message, strpos($message, $EOL)+1);
}
}

// find an empty line between headers and body
// default is set new line
if (strpos($message, $EOL . $EOL)) {
list($headers, $body) = explode($EOL . $EOL, $message, 2);
// next is the standard new line
} else if ($EOL != "\r\n" && strpos($message, "\r\n\r\n")) {
} elseif ($EOL != "\r\n" && strpos($message, "\r\n\r\n")) {
list($headers, $body) = explode("\r\n\r\n", $message, 2);
// next is the other "standard" new line
} else if ($EOL != "\n" && strpos($message, "\n\n")) {
} elseif ($EOL != "\n" && strpos($message, "\n\n")) {
list($headers, $body) = explode("\n\n", $message, 2);
// at last resort find anything that looks like a new line
} else {
@list($headers, $body) = @preg_split("%([\r\n]+)\\1%U", $message, 2);
ErrorHandler::start(E_NOTICE|E_WARNING);
list($headers, $body) = preg_split("%([\r\n]+)\\1%U", $message, 2);
ErrorHandler::stop();
}

$headers = Headers::fromString($headers, $EOL);
Expand Down
4 changes: 2 additions & 2 deletions src/Part.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* @category Zend
* @package Zend_Mime
*/
class Part {

class Part
{
public $type = Mime::TYPE_OCTETSTREAM;
public $encoding = Mime::ENCODING_8BIT;
public $id;
Expand Down

0 comments on commit 36c4a42

Please sign in to comment.