Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2a1e6b0

Browse files
committed
[Mime] allow non-ASCII characters in local part of email
1 parentcd17611 commit2a1e6b0

File tree

4 files changed

+8
-19
lines changed

4 files changed

+8
-19
lines changed

‎src/Symfony/Component/Mime/Encoder/IdnAddressEncoder.php‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,21 @@
1111

1212
namespaceSymfony\Component\Mime\Encoder;
1313

14-
useSymfony\Component\Mime\Exception\AddressEncoderException;
15-
1614
/**
1715
* An IDN email address encoder.
1816
*
1917
* Encodes the domain part of an address using IDN. This is compatible will all
2018
* SMTP servers.
2119
*
22-
*This encoder does not support email addresses withnon-ASCII characters in
23-
* local-part(thesubstring before @).
20+
*Note: It leaves the local part as is. In case there arenon-ASCII characters
21+
*in thelocalpartthen it depends ontheSMTP Server if this is supported.
2422
*
2523
* @author Christian Schmidt
2624
*/
2725
finalclass IdnAddressEncoderimplements AddressEncoderInterface
2826
{
2927
/**
3028
* Encodes the domain part of an address using IDN.
31-
*
32-
* @throws AddressEncoderException If local-part contains non-ASCII characters
3329
*/
3430
publicfunctionencodeString(string$address):string
3531
{
@@ -38,10 +34,6 @@ public function encodeString(string $address): string
3834
$local =substr($address,0,$i);
3935
$domain =substr($address,$i +1);
4036

41-
if (preg_match('/[^\x00-\x7F]/',$local)) {
42-
thrownewAddressEncoderException(sprintf('Non-ASCII characters not supported in local-part os "%s".',$address));
43-
}
44-
4537
if (preg_match('/[^\x00-\x7F]/',$domain)) {
4638
$address =sprintf('%s@%s',$local,idn_to_ascii($domain,0,INTL_IDNA_VARIANT_UTS46));
4739
}

‎src/Symfony/Component/Mime/Tests/Header/MailboxHeaderTest.php‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ public function testgetBodyAsString()
5858
$this->assertEquals('Fabien =?'.$header->getCharset().'?Q?P=8Ftencier?= <fabien@symfony.com>',$header->getBodyAsString());
5959
}
6060

61-
publicfunctiontestUtf8CharsInLocalPartThrows()
61+
publicfunctiontestUtf8CharsInLocalPart()
6262
{
63-
$this->expectException('Symfony\Component\Mime\Exception\AddressEncoderException');
6463
$header =newMailboxHeader('Sender',newAddress('fabïen@symfony.com'));
65-
$header->getBodyAsString();
64+
$this->assertSame('fabïen@symfony.com',$header->getBodyAsString());
6665
}
6766

6867
publicfunctiontestToString()

‎src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ public function testUtf8CharsInDomainAreIdnEncoded()
5555
$this->assertEquals(['Chris Corbyn <chris@xn--swftmailer-78a.org>'],$header->getAddressStrings());
5656
}
5757

58-
publicfunctiontestUtf8CharsInLocalPartThrows()
58+
publicfunctiontestUtf8CharsInLocalPart()
5959
{
60-
$this->expectException('Symfony\Component\Mime\Exception\AddressEncoderException');
6160
$header =newMailboxListHeader('From', [newAddress('chrïs@swiftmailer.org','Chris Corbyn')]);
62-
$header->getAddressStrings();
61+
$this->assertSame(['Chris Corbyn <chrïs@swiftmailer.org>'],$header->getAddressStrings());
6362
}
6463

6564
publicfunctiontestGetMailboxesReturnsNameValuePairs()

‎src/Symfony/Component/Mime/Tests/Header/PathHeaderTest.php‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ public function testAddressIsIdnEncoded()
4949
$this->assertEquals('<chris@xn--swftmailer-78a.org>',$header->getBodyAsString());
5050
}
5151

52-
publicfunctiontestAddressMustBeEncodable()
52+
publicfunctiontestAddressMustBeEncodableWithUtf8CharsInLocalPart()
5353
{
54-
$this->expectException('Symfony\Component\Mime\Exception\AddressEncoderException');
5554
$header =newPathHeader('Return-Path',newAddress('chrïs@swiftmailer.org'));
56-
$header->getBodyAsString();
55+
$this->assertSame('<chrïs@swiftmailer.org>',$header->getBodyAsString());
5756
}
5857

5958
publicfunctiontestSetBody()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp