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

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Sep 13, 2012
2 parents b8473d1 + d8e07da commit 3e018c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/Zend/Mail/Header/GenericHeader.php
Expand Up @@ -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');
}
Expand Down
11 changes: 11 additions & 0 deletions tests/ZendTest/Mail/HeadersTest.php
Expand Up @@ -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");
Expand Down

0 comments on commit 3e018c4

Please sign in to comment.