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

Commit

Permalink
Merge branch 'pull/226' into develop-2.10
Browse files Browse the repository at this point in the history
port to this branch: zendframework#226
  • Loading branch information
glensc committed May 2, 2019
2 parents d7beb63 + ac9637e commit 08c07d0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.10.1 - TBD

### Added

- Nothing.

### Changed

- Nothing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- [#226](https://github.com/zendframework/zend-mail/pull/226) fixes how `Zend\Mail\Header\ListParser::parse()` parses the string if a different quote delimiter
is found when already in quote as desbrided in [#222](https://github.com/zendframework/zend-mail/issues/222). Merges test from
[#224](https://github.com/zendframework/zend-mail/pull/224).

## 2.10.0 - 2018-06-07

### Added
Expand Down
6 changes: 6 additions & 0 deletions src/Header/ListParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ public static function parse($value, array $delims = self::CHAR_DELIMS)
continue;
}

// If already in quote and the character does not match the previously
// matched quote delimiter, we're done here.
if ($inQuote) {
continue;
}

// Otherwise, we're starting a quoted string.
$inQuote = true;
$currentQuoteDelim = $char;
Expand Down
22 changes: 22 additions & 0 deletions test/AddressListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,26 @@ public function testSemicolonSeparator()
$this->assertTrue($addressList->has('[email protected]'));
$this->assertTrue($addressList->has('[email protected]'));
}

/**
* If name-field is quoted with "", then ' inside it should not treated as terminator, but as value.
*/
public function testMixedQuotesInName()
{
$header = '"Bob O\'Reilly" <[email protected]>,[email protected]';

// In previous versions, this throws:
// 'Bob O'Reilly <bob@example.com>,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('[email protected]'));
$this->assertTrue($addressList->has('[email protected]'));
$this->assertEquals("Bob O'Reilly", $addressList->get('[email protected]')->getName());
}
}

0 comments on commit 08c07d0

Please sign in to comment.