Skip to content

Commit 7daf0fe

Browse files
committed
AC-15177: Storefront customer account register: email address format getting converted with different domain format
Only decode if domain contains punycode (contains 'xn--')
1 parent d2126d9 commit 7daf0fe

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

app/code/Magento/Customer/Controller/Account/CreatePost.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -525,18 +525,19 @@ private function getMessageManagerSuccessMessage(): MessageInterface
525525
private function decodePunycodeEmail(): void
526526
{
527527
$email = $this->getRequest()->getParam('email');
528+
if (!$email || strpos($email, '@') === false) {
529+
return;
530+
}
528531

529532
// Split local part and domain
530533
[$localPart, $domain] = explode('@', $email, 2);
531534

532-
// Decode only the domain part
533-
if (function_exists('idn_to_utf8')) {
535+
// Only decode if domain contains punycode (contains 'xn--')
536+
if (function_exists('idn_to_utf8') && strpos($domain, 'xn--') !== false) {
534537
$decodedDomain = idn_to_utf8($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
535-
if ($decodedDomain !== false) {
536-
$domain = $decodedDomain;
538+
if ($decodedDomain !== false && $decodedDomain !== $domain) {
539+
$this->getRequest()->setParam('email', $localPart . '@' . $decodedDomain);
537540
}
538541
}
539-
540-
$this->getRequest()->setParam('email', $localPart . '@' . $domain);
541542
}
542543
}

0 commit comments

Comments
 (0)