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' into acceptHandling
Browse files Browse the repository at this point in the history
Conflicts:
	library/Zend/Http/Header/AbstractAccept.php
	library/Zend/Http/Header/AcceptEncoding.php
	library/Zend/Http/Header/AcceptLanguage.php
	tests/Zend/Http/Header/AcceptCharsetTest.php
	tests/Zend/Http/Header/AcceptEncodingTest.php
	tests/Zend/Http/Header/AcceptLanguageTest.php
	tests/Zend/Http/Header/AcceptTest.php
  • Loading branch information
Freeaqingme committed Jul 14, 2012
5 parents 5545b5e + 757d24d + 02e6999 + edaf480 + 1ede9ce commit 8630680
Show file tree
Hide file tree
Showing 4 changed files with 20 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
1 change: 1 addition & 0 deletions test/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

namespace ZendTest\Mime;

use Zend\Mime;

/**
Expand Down
1 change: 1 addition & 0 deletions test/PartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

namespace ZendTest\Mime;

use Zend\Mime;

/**
Expand Down

0 comments on commit 8630680

Please sign in to comment.