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

Commit 08c07d0

Browse files
committed
Merge branch 'pull/226' into develop-2.10
port to this branch: zendframework#226
2 parents d7beb63 + ac9637e commit 08c07d0

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22

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

5+
## 2.10.1 - TBD
6+
7+
### Added
8+
9+
- Nothing.
10+
11+
### Changed
12+
13+
- Nothing.
14+
15+
### Deprecated
16+
17+
- Nothing.
18+
19+
### Removed
20+
21+
- Nothing.
22+
23+
### Fixed
24+
25+
- [#226](https://github.com/zendframework/zend-mail/pull/226) fixes how `Zend\Mail\Header\ListParser::parse()` parses the string if a different quote delimiter
26+
is found when already in quote as desbrided in [#222](https://github.com/zendframework/zend-mail/issues/222). Merges test from
27+
[#224](https://github.com/zendframework/zend-mail/pull/224).
28+
529
## 2.10.0 - 2018-06-07
630

731
### Added

src/Header/ListParser.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ public static function parse($value, array $delims = self::CHAR_DELIMS)
7676
continue;
7777
}
7878

79+
// If already in quote and the character does not match the previously
80+
// matched quote delimiter, we're done here.
81+
if ($inQuote) {
82+
continue;
83+
}
84+
7985
// Otherwise, we're starting a quoted string.
8086
$inQuote = true;
8187
$currentQuoteDelim = $char;

test/AddressListTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,26 @@ public function testSemicolonSeparator()
144144
$this->assertTrue($addressList->has('[email protected]'));
145145
$this->assertTrue($addressList->has('[email protected]'));
146146
}
147+
148+
/**
149+
* If name-field is quoted with "", then ' inside it should not treated as terminator, but as value.
150+
*/
151+
public function testMixedQuotesInName()
152+
{
153+
$header = '"Bob O\'Reilly" <[email protected]>,[email protected]';
154+
155+
// In previous versions, this throws:
156+
// 'Bob O'Reilly <[email protected]>,blah' can not be matched against dot-atom format
157+
// hence the try/catch block, to allow finding the root cause.
158+
try {
159+
$to = Header\To::fromString('To:' . $header);
160+
} catch (InvalidArgumentException $e) {
161+
$this->fail('Header\To::fromString should not throw. Exception message: ' . $e->getMessage());
162+
}
163+
164+
$addressList = $to->getAddressList();
165+
$this->assertTrue($addressList->has('[email protected]'));
166+
$this->assertTrue($addressList->has('[email protected]'));
167+
$this->assertEquals("Bob O'Reilly", $addressList->get('[email protected]')->getName());
168+
}
147169
}

0 commit comments

Comments
 (0)