From c3dd482cceb1c6b86c8eb80f81e0dfc535ef3648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Tue, 5 Mar 2019 00:49:15 +0200 Subject: [PATCH] add test for #147 regression --- test/AddressListTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/AddressListTest.php b/test/AddressListTest.php index 3db6805a..c7d43ff5 100644 --- a/test/AddressListTest.php +++ b/test/AddressListTest.php @@ -144,4 +144,25 @@ public function testSemicolonSeparator() $this->assertTrue($addressList->has('asda.fasd@example.net')); $this->assertTrue($addressList->has('root@example.org')); } + + /** + * If name-field is quoted with "", then ' inside it should not treated as terminator, but as value. + */ + public function testMixedQuotesInName() { + $header = '"Bob O\'Reilly" ,blah@example.com'; + + // In previous versions, this throws: + // 'Bob O'Reilly ,blah' can not be matched against dot-atom format + // hence the try/catch block, to allow finding the root cause. + try { + $to = Header\To::fromString('To:' . $header); + } catch (InvalidArgumentException $e) { + $this->fail('Header\To::fromString should not throw. Exception message: ' . $e->getMessage()); + } + + $addressList = $to->getAddressList(); + $this->assertTrue($addressList->has('bob@example.com')); + $this->assertTrue($addressList->has('blah@example.com')); + $this->assertEquals("Bob O'Reilly", $addressList->get('bob@example.com')->getName()); + } }