Skip to content

Commit 583b4dd

Browse files
committed
Merge branch 'ACP2E-717' of https://github.com/magento-l3/magento2ce into L3-PR-2022-04-19-v2
2 parents ac0c588 + 654f911 commit 583b4dd

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/internal/Magento/Framework/Mail/AddressConverter.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\Framework\Mail\Exception\InvalidArgumentException;
1111

1212
/**
13-
* Class AddressConverter
13+
* Convert and filter email addresses
1414
*/
1515
class AddressConverter
1616
{
@@ -60,10 +60,14 @@ private function convertEmailUserToAscii(string $email): string
6060
if (preg_match('/^(.+)@([^@]+)$/', $email, $matches)) {
6161
$user = $matches[1];
6262
$hostname = $matches[2];
63-
$userEncoded = idn_to_ascii($user, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
63+
$userEncoded = idn_to_ascii($user, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46, $idnaInfo);
6464
if ($userEncoded == $user) {
6565
return $email;
6666
}
67+
68+
if ($userEncoded === false && array_key_exists('result', $idnaInfo)) {
69+
$userEncoded = $idnaInfo['result'];
70+
}
6771
$email = sprintf('%s@%s', $userEncoded, $hostname);
6872
}
6973
return $email;

lib/internal/Magento/Framework/Mail/Test/Unit/AddressConverterTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ public function convertDataProvider(): array
7070
'name' => 'Test',
7171
'emailExpected' => '[email protected]',
7272
'nameExpected' => 'Test'
73+
],
74+
[
75+
'email' => '[email protected]',
76+
'name' => 'Test',
77+
'emailExpected' => '[email protected]',
78+
'nameExpected' => 'Test'
79+
],
80+
[
81+
'email' => 'tést.-è[email protected]',
82+
'name' => 'Test',
83+
'emailExpected' => '[email protected]',
84+
'nameExpected' => 'Test'
7385
]
7486
];
7587
}

0 commit comments

Comments
 (0)