diff --git a/src/AddressList.php b/src/AddressList.php index 393d27fc..9a00d68f 100644 --- a/src/AddressList.php +++ b/src/AddressList.php @@ -90,7 +90,7 @@ public function addMany(array $addresses) */ public function addFromString($address) { - if (! preg_match('/^((?P.*?)<(?P[^>]+)>|(?P.+))$/', $address, $matches)) { + if (! preg_match('/^((?P.*)<(?P[^>]+)>|(?P.+))$/', $address, $matches)) { throw new Exception\InvalidArgumentException('Invalid address format'); } diff --git a/test/AddressListTest.php b/test/AddressListTest.php index 8ba08879..0386d31a 100644 --- a/test/AddressListTest.php +++ b/test/AddressListTest.php @@ -15,10 +15,13 @@ /** * @group Zend_Mail - * @covers Zend\Mail\AddressList + * @covers \Zend\Mail\AddressList */ class AddressListTest extends TestCase { + /** @var AddressList $list */ + private $list; + public function setUp() { $this->list = new AddressList(); diff --git a/test/HeadersTest.php b/test/HeadersTest.php index 367ec6c2..be5a55ce 100644 --- a/test/HeadersTest.php +++ b/test/HeadersTest.php @@ -15,7 +15,7 @@ /** * @group Zend_Mail - * @covers Zend\Mail\Headers + * @covers \Zend\Mail\Headers */ class HeadersTest extends TestCase { @@ -483,4 +483,36 @@ public function testAddressListGetEncodedFieldValueWithUtf8Domain() $encodedValue = $to->getFieldValue(Header\HeaderInterface::FORMAT_ENCODED); $this->assertEquals('local-part@xn---umlaut-4wa.de', $encodedValue); } + + /** + * Test ">" being part of email "comment". + * + * Example Email-header: + * "Foo '); + + $address = $to->getAddressList()->get('foo.bar@test.com'); + $this->assertEquals('õlu getName()); + $this->assertEquals('foo.bar@test.com', $address->getEmail()); + + $encodedValue = $to->getFieldValue(Header\HeaderInterface::FORMAT_ENCODED); + $this->assertEquals('=?UTF-8?Q?=C3=B5lu=20', $encodedValue); + + $encodedValue = $to->getFieldValue(Header\HeaderInterface::FORMAT_RAW); + // FIXME: shouldn't the "name" part be in quotes? + $this->assertEquals('õlu ', $encodedValue); + } }