Skip to content

Commit

Permalink
Message: slashes in "display-name" are stripped
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jul 1, 2019
1 parent d1e952f commit 82fb366
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Mail/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ private function formatEmail(string $email, string $name = null): array
{
if (!$name && preg_match('#^(.+) +<(.*)>\z#', $email, $matches)) {
[, $name, $email] = $matches;
$name = stripslashes($name);
$tmp = substr($name, 1, -1);
if ($name === '"' . $tmp . '"') {
$name = stripslashes($tmp);
$name = $tmp;
}
}
return [$email => $name];
Expand Down
2 changes: 1 addition & 1 deletion tests/Mail/Mail.email.parse.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $mail->setFrom('"Žluťouč\"k\ý kůň" <[email protected]>');
Assert::same(['[email protected]' => 'Žluťouč"ký kůň'], $mail->getFrom());

$mail->setFrom('The\Mail <[email protected]>');
Assert::same(['[email protected]' => 'The\Mail'], $mail->getFrom());
Assert::same(['[email protected]' => 'TheMail'], $mail->getFrom());

$mail->setFrom('The.Mail <[email protected]>');
Assert::same(['[email protected]' => 'The.Mail'], $mail->getFrom());
2 changes: 1 addition & 1 deletion tests/Mail/Mail.email.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Reply-To: =?UTF-8?B?xb1sdcWlb3XEjWvDvSBrxa/FiA==?= <[email protected]>,
John Doe <[email protected]>
To: =?UTF-8?B?xb1sdcWlb3XEjWvDvSAia8WvxYgi?= <[email protected]>,
John 'jd' Doe <[email protected]>
Cc: "The\\Mail" <[email protected]>,John Doe <[email protected]>,"The.Mail"
Cc: TheMail <[email protected]>,John Doe <[email protected]>,"The.Mail"
<[email protected]>
Bcc: =?UTF-8?B?xb1sdcWlb3XEjWvDvSBrxa/FiA==?= <[email protected]>,
[email protected]
Expand Down

0 comments on commit 82fb366

Please sign in to comment.