-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Mime] allow non-ASCII characters in local part of email #36178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,11 @@ | |
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Mailer\Envelope; | ||
use Symfony\Component\Mailer\Exception\InvalidArgumentException; | ||
use Symfony\Component\Mailer\Exception\LogicException; | ||
use Symfony\Component\Mime\Address; | ||
use Symfony\Component\Mime\Header\Headers; | ||
use Symfony\Component\Mime\Header\PathHeader; | ||
use Symfony\Component\Mime\Message; | ||
use Symfony\Component\Mime\RawMessage; | ||
|
||
|
@@ -27,6 +29,13 @@ public function testConstructorWithAddressSender() | |
$this->assertEquals(new Address('fabien@symfony.com'), $e->getSender()); | ||
} | ||
|
||
public function testConstructorWithAddressSenderAndNonAsciiCharactersInLocalPartOfAddress() | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('Invalid sender "fabièn@symfony.com": non-ASCII characters not supported in local-part of email.'); | ||
new Envelope(new Address('fabièn@symfony.com'), [new Address('thomas@symfony.com')]); | ||
} | ||
|
||
public function testConstructorWithNamedAddressSender() | ||
{ | ||
$e = new Envelope(new Address('fabien@symfony.com', 'Fabien'), [new Address('thomas@symfony.com')]); | ||
|
@@ -57,19 +66,27 @@ public function testSenderFromHeaders() | |
$headers->addPathHeader('Return-Path', new Address('return@symfony.com', 'return')); | ||
$headers->addMailboxListHeader('To', ['from@symfony.com']); | ||
$e = Envelope::create(new Message($headers)); | ||
$this->assertEquals(new Address('return@symfony.com', 'return'), $e->getSender()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fabpot here is a slight change in behavior now since we use |
||
$this->assertEquals(new Address('return@symfony.com'), $e->getSender()); | ||
|
||
$headers = new Headers(); | ||
$headers->addMailboxHeader('Sender', new Address('sender@symfony.com', 'sender')); | ||
$headers->addMailboxListHeader('To', ['from@symfony.com']); | ||
$e = Envelope::create(new Message($headers)); | ||
$this->assertEquals(new Address('sender@symfony.com', 'sender'), $e->getSender()); | ||
$this->assertEquals(new Address('sender@symfony.com'), $e->getSender()); | ||
|
||
$headers = new Headers(); | ||
$headers->addMailboxListHeader('From', [new Address('from@symfony.com', 'from'), 'some@symfony.com']); | ||
$headers->addMailboxListHeader('To', ['from@symfony.com']); | ||
$e = Envelope::create(new Message($headers)); | ||
$this->assertEquals(new Address('from@symfony.com', 'from'), $e->getSender()); | ||
$this->assertEquals(new Address('from@symfony.com'), $e->getSender()); | ||
} | ||
|
||
public function testSenderFromHeadersFailsWithNonAsciiCharactersInLocalPart() | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('Invalid sender "fabièn@symfony.com": non-ASCII characters not supported in local-part of email.'); | ||
$message = new Message(new Headers(new PathHeader('Return-Path', new Address('fabièn@symfony.com')))); | ||
Envelope::create($message)->getSender(); | ||
} | ||
|
||
public function testSenderFromHeadersWithoutFrom() | ||
|
@@ -78,7 +95,7 @@ public function testSenderFromHeadersWithoutFrom() | |
$headers->addMailboxListHeader('To', ['from@symfony.com']); | ||
$e = Envelope::create($message = new Message($headers)); | ||
$message->getHeaders()->addMailboxListHeader('From', [new Address('from@symfony.com', 'from')]); | ||
$this->assertEquals(new Address('from@symfony.com', 'from'), $e->getSender()); | ||
$this->assertEquals(new Address('from@symfony.com'), $e->getSender()); | ||
} | ||
|
||
public function testRecipientsFromHeaders() | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.