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

Commit

Permalink
Merge branch 'hotfix/3789' into develop
Browse files Browse the repository at this point in the history
Forward port #3789
  • Loading branch information
weierophinney committed Feb 19, 2013
2 parents 74b1979 + 99f6711 commit 2a3e782
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
4 changes: 3 additions & 1 deletion library/Zend/Mail/Header/AbstractAddressList.php
Expand Up @@ -43,7 +43,9 @@ public static function fromString($headerLine)
{
$decodedLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8');
// split into name/value
list($fieldName, $fieldValue) = explode(': ', $decodedLine, 2);
list($fieldName, $fieldValue) = explode(':', $decodedLine, 2);
$fieldName = trim($fieldName);
$fieldValue = trim($fieldValue);

if (strtolower($fieldName) !== static::$type) {
throw new Exception\InvalidArgumentException(sprintf(
Expand Down
44 changes: 39 additions & 5 deletions tests/ZendTest/Mail/Header/AddressListHeaderTest.php
Expand Up @@ -105,11 +105,11 @@ public function getStringHeaders()
{
$value = $this->getExpectedFieldValue();
return array(
array('Cc: ' . $value, 'Zend\Mail\Header\Cc'),
array('Bcc: ' . $value, 'Zend\Mail\Header\Bcc'),
array('From: ' . $value, 'Zend\Mail\Header\From'),
array('Reply-To: ' . $value, 'Zend\Mail\Header\ReplyTo'),
array('To: ' . $value, 'Zend\Mail\Header\To'),
'cc' => array('Cc: ' . $value, 'Zend\Mail\Header\Cc'),
'bcc' => array('Bcc: ' . $value, 'Zend\Mail\Header\Bcc'),
'from' => array('From: ' . $value, 'Zend\Mail\Header\From'),
'reply-to' => array('Reply-To: ' . $value, 'Zend\Mail\Header\ReplyTo'),
'to' => array('To: ' . $value, 'Zend\Mail\Header\To'),
);
}

Expand All @@ -133,4 +133,38 @@ public function testDeserializationFromString($headerLine, $class)
$address = $list->get('fw-announce@lists.zend.com');
$this->assertEquals('ZF Announce List', $address->getName());
}

public function getStringHeadersWithNoWhitespaceSeparator()
{
$value = $this->getExpectedFieldValue();
return array(
'cc' => array('Cc:' . $value, 'Zend\Mail\Header\Cc'),
'bcc' => array('Bcc:' . $value, 'Zend\Mail\Header\Bcc'),
'from' => array('From:' . $value, 'Zend\Mail\Header\From'),
'reply-to' => array('Reply-To:' . $value, 'Zend\Mail\Header\ReplyTo'),
'to' => array('To:' . $value, 'Zend\Mail\Header\To'),
);
}

/**
* @group 3789
* @dataProvider getStringHeadersWithNoWhitespaceSeparator
*/
public function testAllowsNoWhitespaceBetweenHeaderAndValue($headerLine, $class)
{
$callback = sprintf('%s::fromString', $class);
$header = call_user_func($callback, $headerLine);
$this->assertInstanceOf($class, $header);
$list = $header->getAddressList();
$this->assertEquals(3, count($list));
$this->assertTrue($list->has('zf-devteam@zend.com'));
$this->assertTrue($list->has('zf-contributors@lists.zend.com'));
$this->assertTrue($list->has('fw-announce@lists.zend.com'));
$address = $list->get('zf-devteam@zend.com');
$this->assertEquals('ZF DevTeam', $address->getName());
$address = $list->get('zf-contributors@lists.zend.com');
$this->assertNull($address->getName());
$address = $list->get('fw-announce@lists.zend.com');
$this->assertEquals('ZF Announce List', $address->getName());
}
}

0 comments on commit 2a3e782

Please sign in to comment.