Permalink
Browse files

Merge branch 'release'

  • Loading branch information...
2 parents b8473d1 + d8e07da commit 3e018c4b97b362ecd2db34ef6ae4cdca18092cf5 @weierophinney weierophinney committed Sep 13, 2012
Showing with 13 additions and 2 deletions.
  1. +2 −2 library/Zend/Mail/Header/GenericHeader.php
  2. +11 −0 tests/ZendTest/Mail/HeadersTest.php
View
4 library/Zend/Mail/Header/GenericHeader.php
@@ -37,11 +37,11 @@ class GenericHeader implements HeaderInterface, UnstructuredInterface
public static function fromString($headerLine)
{
$decodedLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8');
- $parts = explode(': ', $decodedLine, 2);
+ $parts = explode(':', $decodedLine, 2);
if (count($parts) != 2) {
throw new Exception\InvalidArgumentException('Header must match with the format "name: value"');
}
- $header = new static($parts[0], $parts[1]);
+ $header = new static($parts[0], ltrim($parts[1]));
if ($decodedLine != $headerLine) {
$header->setEncoding('UTF-8');
}
View
11 tests/ZendTest/Mail/HeadersTest.php
@@ -39,6 +39,17 @@ public function testHeadersFromStringFactoryCreatesSingleObject()
$this->assertEquals('foo-bar', $header->getFieldValue());
}
+ public function testHeadersFromStringFactoryHandlesMissingWhitespace()
+ {
+ $headers = Mail\Headers::fromString("Fake:foo-bar");
+ $this->assertEquals(1, $headers->count());
+
+ $header = $headers->get('fake');
+ $this->assertInstanceOf('Zend\Mail\Header\GenericHeader', $header);
+ $this->assertEquals('Fake', $header->getFieldName());
+ $this->assertEquals('foo-bar', $header->getFieldValue());
+ }
+
public function testHeadersFromStringFactoryCreatesSingleObjectWithContinuationLine()
{
$headers = Mail\Headers::fromString("Fake: foo-bar,\r\n blah-blah");

0 comments on commit 3e018c4

Please sign in to comment.