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

Commit

Permalink
added test case and optional strict flag
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwindell committed Jul 13, 2012
1 parent b6cdec7 commit 8ccf77d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Decode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down

0 comments on commit 8ccf77d

Please sign in to comment.