Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 19 additions & 1 deletion src/Parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,25 @@ public function parse(string $emails, bool $multiple = true, string $encoding =
if (')' == $curChar) {
--$commentNestLevel;
if ($commentNestLevel <= 0) {
// End of comment - save it
if ($emailAddress['comment_temp']) {
$emailAddress['comments'][] = $emailAddress['comment_temp'];
$emailAddress['comment_temp'] = '';
}
$state = self::STATE_ADDRESS;
} else {
// Nested comment closing parenthesis
$emailAddress['comment_temp'] .= $curChar;
}
} elseif ('(' == $curChar) {
++$commentNestLevel;
if ($commentNestLevel > 1) {
// Nested comment opening parenthesis
$emailAddress['comment_temp'] .= $curChar;
}
} else {
// Regular comment character
$emailAddress['comment_temp'] .= $curChar;
}

break;
Expand Down Expand Up @@ -740,6 +755,8 @@ private function buildEmailAddressArray(): array
'address_temp' => '',
'address_temp_period' => 0,
'special_char_in_substate' => null,
'comment_temp' => '',
'comments' => [],
];

return $emailAddress;
Expand Down Expand Up @@ -846,7 +863,8 @@ private function addAddress(
'domain' => $emailAddress['domain'],
'ip' => $emailAddress['ip'],
'invalid' => $emailAddress['invalid'],
'invalid_reason' => $emailAddress['invalid_reason'], ];
'invalid_reason' => $emailAddress['invalid_reason'],
'comments' => $emailAddress['comments'], ];

// Build the proper address by hand (has comments stripped out and should have quotes in the proper places)
if (!$emailAddrDef['invalid']) {
Expand Down
Loading