From 8ccf77dac7faafffcdfa749c687f62ed70bbc98e Mon Sep 17 00:00:00 2001 From: David Windell Date: Fri, 13 Jul 2012 10:51:49 +0100 Subject: [PATCH] added test case and optional strict flag --- src/Decode.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Decode.php b/src/Decode.php index dc30256..a2898c9 100644 --- a/src/Decode.php +++ b/src/Decode.php @@ -100,9 +100,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(); @@ -117,9 +118,11 @@ public static function splitMessage($message, &$headers, &$body, $EOL = Mime::LI } // see @ZF2-372, pops the first line off a message if it doesn't contain a header - $parts = explode(': ', $firstline, 2); - if (count($parts) != 2) { - $message = substr($message, strpos($message, $EOL)+1); + 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