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

Treat quote as value if already in quote using another delimiter #226

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

- Nothing.
- [#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.

## 2.10.0 - 2018-06-07

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
26 changes: 26 additions & 0 deletions test/Header/ListParser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* @see https://github.com/zendframework/zend-mail for the canonical source repository
* @copyright Copyright (c) 2005-2019 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-mail/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\Mail\Header;

use PHPUnit\Framework\TestCase;
use Zend\Mail\Header\ListParser;

/**
* @covers Zend\Mail\Header\ListParser<extended>
*/
class ListParserTest extends TestCase
{
public function testParseIgnoreQuoteDelimiterIfAlreadyInQuote()
{
$parsed = ListParser::parse('"john\'doe" <[email protected]>,jane <[email protected]>');
$this->assertEquals($parsed, [
silvadiego marked this conversation as resolved.
Show resolved Hide resolved
'"john\'doe" <[email protected]>',
'jane <[email protected]>'
]);
}
}