Skip to content

Commit

Permalink
Merge pull request #5 from mvdnbrk/fix-escaped-chars
Browse files Browse the repository at this point in the history
A quoted contact named should not be quoted.
  • Loading branch information
mvdnbrk authored Aug 23, 2018
2 parents 796074d + 7ffeb9c commit 096ac99
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -53,6 +53,6 @@ public function __construct($name, $email, $mailboxHash = null)

$this->mailboxHash = $mailboxHash;

$this->full = $name . ' <' . $email . '>';
$this->full = $this->name . ' <' . $email . '>';
}
}
12 changes: 12 additions & 0 deletions tests/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <john@example.com>', $c->full);

$c = new Contact("'John'", 'john@example.com', 'hash');
$this->assertEquals('John', $c->name);
$this->assertEquals('John <john@example.com>', $c->full);
}

/** @test */
public function hash_is_optional()
{
Expand Down

0 comments on commit 096ac99

Please sign in to comment.