diff --git a/CHANGELOG.md b/CHANGELOG.md index fcbd82c..f158abe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to `postmark-inbound` will be documented in this file. ## [Unreleased] +## [2.3.4] - 2018-08-23 + +### Fixed + +- A quoted contact named should not be quoted. ([#5](https://github.com/mvdnbrk/postmark-inbound/pull/5)) + ## [2.3.3] - 2018-05-04 ### Fixed @@ -129,7 +135,8 @@ All notable changes to `postmark-inbound` will be documented in this file. - Code style fixes. [`7c8eb86`](https://github.com/mvdnbrk/postmark-inbound/commit/7c8eb86cbf9719fbb568160decf4ae8dc735ce98) - PHPUnit minimum version set to 5.4.3. [`c2331a4`](https://github.com/mvdnbrk/postmark-inbound/commit/c2331a48557ef88f67b2a7df1176cccf05a2b3e8) -[Unreleased]: https://github.com/mvdnbrk/postmark-inbound/compare/v2.3.3...HEAD +[Unreleased]: https://github.com/mvdnbrk/postmark-inbound/compare/v2.3.4...HEAD +[2.3.4]: https://github.com/mvdnbrk/postmark-inbound/compare/v2.3.3...v2.3.4 [2.3.3]: https://github.com/mvdnbrk/postmark-inbound/compare/v2.3.2...v2.3.3 [2.3.2]: https://github.com/mvdnbrk/postmark-inbound/compare/v2.3.1...v2.3.2 [2.3.1]: https://github.com/mvdnbrk/postmark-inbound/compare/v2.3.0...v2.3.1 diff --git a/src/Contact.php b/src/Contact.php index 09de76c..acca8eb 100644 --- a/src/Contact.php +++ b/src/Contact.php @@ -43,7 +43,7 @@ class Contact */ public function __construct($name, $email, $mailboxHash = null) { - $this->name = trim($name); + $this->name = trim($name, ' "\''); $this->email = (new Collection(explode(' ', $email))) ->filter(function ($value) { @@ -53,6 +53,6 @@ public function __construct($name, $email, $mailboxHash = null) $this->mailboxHash = $mailboxHash; - $this->full = $name . ' <' . $email . '>'; + $this->full = $this->name . ' <' . $email . '>'; } } diff --git a/tests/ContactTest.php b/tests/ContactTest.php index 258f342..2102a14 100644 --- a/tests/ContactTest.php +++ b/tests/ContactTest.php @@ -50,6 +50,18 @@ public function email_address_with_non_allowed_prefix_is_stripped_off() $this->assertEquals('john@example.com', $c->email); } + /** @test */ + public function a_quoted_name_should_be_unquoted() + { + $c = new Contact('"John"', 'john@example.com', 'hash'); + $this->assertEquals('John', $c->name); + $this->assertEquals('John ', $c->full); + + $c = new Contact("'John'", 'john@example.com', 'hash'); + $this->assertEquals('John', $c->name); + $this->assertEquals('John ', $c->full); + } + /** @test */ public function hash_is_optional() {