Skip to content

Commit 82fb366

Browse files
committed
Message: slashes in "display-name" are stripped
see https://tools.ietf.org/html/rfc2822
1 parent d1e952f commit 82fb366

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/Mail/Message.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ private function formatEmail(string $email, string $name = null): array
143143
{
144144
if (!$name && preg_match('#^(.+) +<(.*)>\z#', $email, $matches)) {
145145
[, $name, $email] = $matches;
146+
$name = stripslashes($name);
146147
$tmp = substr($name, 1, -1);
147148
if ($name === '"' . $tmp . '"') {
148-
$name = stripslashes($tmp);
149+
$name = $tmp;
149150
}
150151
}
151152
return [$email => $name];

tests/Mail/Mail.email.parse.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ $mail->setFrom('"Žluťouč\"k\ý kůň" <[email protected]>');
3434
Assert::same(['[email protected]' => 'Žluťouč"ký kůň'], $mail->getFrom());
3535

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

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

tests/Mail/Mail.email.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Reply-To: =?UTF-8?B?xb1sdcWlb3XEjWvDvSBrxa/FiA==?= <[email protected]>,
4646
John Doe <[email protected]>
4747
To: =?UTF-8?B?xb1sdcWlb3XEjWvDvSAia8WvxYgi?= <[email protected]>,
4848
John 'jd' Doe <[email protected]>
49-
Cc: "The\\Mail" <[email protected]>,John Doe <[email protected]>,"The.Mail"
49+
Cc: TheMail <[email protected]>,John Doe <[email protected]>,"The.Mail"
5050
5151
Bcc: =?UTF-8?B?xb1sdcWlb3XEjWvDvSBrxa/FiA==?= <[email protected]>,
5252

0 commit comments

Comments
 (0)