diff --git a/CHANGELOG.md b/CHANGELOG.md index ebf104f..6a1c2a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,10 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- Nothing. +- [#36](https://github.com/zendframework/zend-mime/pull/36) fixes + `Zend\Mime\Decode::splitMessage` to set `Zend\Mail\Headers` + instance always for `$headers` parameter. Before, when messages + without headers was provided, `$headers` was an empty array. ## 2.7.1 - 2018-05-14 diff --git a/src/Decode.php b/src/Decode.php index d4c181f..a104ce8 100644 --- a/src/Decode.php +++ b/src/Decode.php @@ -108,7 +108,7 @@ public static function splitMessage($message, &$headers, &$body, $EOL = Mime::LI $firstlinePos = strpos($message, "\n"); $firstline = $firstlinePos === false ? $message : substr($message, 0, $firstlinePos); if (! preg_match('%^[^\s]+[^:]*:%', $firstline)) { - $headers = []; + $headers = new Headers(); // TODO: we're ignoring \r for now - is this function fast enough and is it safe to assume noone needs \r? $body = str_replace(["\r", "\n"], ['', $EOL], $message); return; diff --git a/test/DecodeTest.php b/test/DecodeTest.php new file mode 100644 index 0000000..ca52f93 --- /dev/null +++ b/test/DecodeTest.php @@ -0,0 +1,25 @@ +