Skip to content

Commit 12bda70

Browse files
committed
Merge remote-tracking branch 'origin/AC-15177' into spartans_pr_03092025
2 parents 18198cf + 7daf0fe commit 12bda70

File tree

4 files changed

+87
-8
lines changed

4 files changed

+87
-8
lines changed

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

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -226,6 +226,7 @@ public function __construct(
226226
* Retrieve cookie manager
227227
*
228228
* @deprecated 100.1.0
229+
* @see https://jira.corp.magento.com/browse/MAGETWO-71174
229230
* @return \Magento\Framework\Stdlib\Cookie\PhpCookieManager
230231
*/
231232
private function getCookieManager()
@@ -242,6 +243,7 @@ private function getCookieManager()
242243
* Retrieve cookie metadata factory
243244
*
244245
* @deprecated 100.1.0
246+
* @see https://jira.corp.magento.com/browse/MAGETWO-71174
245247
* @return \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
246248
*/
247249
private function getCookieMetadataFactory()
@@ -361,6 +363,8 @@ public function execute()
361363
return $this->resultRedirectFactory->create()
362364
->setUrl($this->_redirect->error($url));
363365
}
366+
367+
$this->decodePunycodeEmail();
364368
$this->session->regenerateId();
365369
try {
366370
$address = $this->extractAddress();
@@ -512,4 +516,28 @@ private function getMessageManagerSuccessMessage(): MessageInterface
512516

513517
return $message;
514518
}
519+
520+
/**
521+
* Convert punycode email back to Unicode
522+
*
523+
* @return void
524+
*/
525+
private function decodePunycodeEmail(): void
526+
{
527+
$email = $this->getRequest()->getParam('email');
528+
if (!$email || strpos($email, '@') === false) {
529+
return;
530+
}
531+
532+
// Split local part and domain
533+
[$localPart, $domain] = explode('@', $email, 2);
534+
535+
// Only decode if domain contains punycode (contains 'xn--')
536+
if (function_exists('idn_to_utf8') && strpos($domain, 'xn--') !== false) {
537+
$decodedDomain = idn_to_utf8($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
538+
if ($decodedDomain !== false && $decodedDomain !== $domain) {
539+
$this->getRequest()->setParam('email', $localPart . '@' . $decodedDomain);
540+
}
541+
}
542+
}
515543
}

app/code/Magento/Customer/view/frontend/templates/form/forgotpassword.phtml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*
66
* @var $block \Magento\Customer\Block\Account\Forgotpassword
77
*/
@@ -10,6 +10,7 @@
1010

1111
/** @var \Magento\Customer\Block\Account\Forgotpassword $block */
1212
if (!$block->getButtonLockManager()) {
13+
// phpcs:ignore
1314
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
1415
$block->setButtonLockManager(
1516
$objectManager->get(\Magento\Framework\View\Element\ButtonLockManager::class)
@@ -27,7 +28,7 @@ if (!$block->getButtonLockManager()) {
2728
<div class="field email required">
2829
<label for="email_address" class="label"><span><?= $escaper->escapeHtml(__('Email')) ?></span></label>
2930
<div class="control">
30-
<input type="email" name="email" alt="email" id="email_address" class="input-text" value="<?= $escaper->escapeHtmlAttr($block->getEmailValue()) ?>" data-mage-init='{"mage/trim-input":{}}' data-validate="{required:true, 'validate-email':true}">
31+
<input type="email" name="email" alt="email" id="email_address" class="input-text" value="<?= $escaper->escapeHtmlAttr($block->getEmailValue()) ?>" data-validate="{required:true, 'validate-email':true}">
3132
</div>
3233
</div>
3334
<?= $block->getChildHtml('form_additional_info') ?>

app/code/Magento/Customer/view/frontend/templates/form/login.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66

77
// phpcs:disable Generic.Files.LineLength.TooLong
88

99
/** @var \Magento\Customer\Block\Form\Login $block */
1010
if (!$block->getButtonLockManager()) {
11+
// phpcs:ignore
1112
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
1213
$block->setButtonLockManager(
1314
$objectManager->get(\Magento\Framework\View\Element\ButtonLockManager::class)
@@ -35,7 +36,6 @@ if (!$block->getButtonLockManager()) {
3536
<?php if ($block->isAutocompleteDisabled()): ?> autocomplete="off"<?php endif; ?>
3637
id="email" type="email" class="input-text"
3738
title="<?= $escaper->escapeHtmlAttr(__('Email')) ?>"
38-
data-mage-init='{"mage/trim-input":{}}'
3939
data-validate="{required:true, 'validate-email':true}">
4040
</div>
4141
</div>

dev/tests/integration/testsuite/Magento/Customer/Controller/Account/CreatePostTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,37 @@ public function testNoConfirmCreatePostAction(): void
173173
$this->assertNull($customer->getData('increment_id'));
174174
}
175175

176+
/**
177+
* @magentoDbIsolation enabled
178+
* @magentoAppIsolation enabled
179+
* @magentoConfigFixture current_website customer/create_account/confirm 0
180+
* @magentoConfigFixture current_store customer/create_account/default_group 1
181+
* @magentoConfigFixture current_store customer/create_account/generate_human_friendly_id 0
182+
*
183+
* @dataProvider emailDataProvider
184+
* @param string $email
185+
* @param string $expectedEmail
186+
* @return void
187+
* @throws NoSuchEntityException
188+
*/
189+
public function testNoConfirmCreatePostPunycodeEmailAction(string $email, string $expectedEmail): void
190+
{
191+
$this->fillRequestWithAccountData($email);
192+
$this->dispatch('customer/account/createPost');
193+
$this->assertRedirect($this->stringEndsWith('customer/account/'));
194+
$this->assertSessionMessages(
195+
$this->containsEqual(
196+
(string)__('Thank you for registering with %1.', $this->storeManager->getStore()->getFrontendName())
197+
),
198+
MessageInterface::TYPE_SUCCESS
199+
);
200+
$customer = $this->customerRegistry->retrieveByEmail($expectedEmail);
201+
//Assert customer group
202+
$this->assertEquals(1, $customer->getDataModel()->getGroupId());
203+
//Assert customer email
204+
$this->assertEquals($expectedEmail, $customer->getData('email'));
205+
}
206+
176207
/**
177208
* @magentoDbIsolation enabled
178209
* @magentoAppIsolation enabled
@@ -289,6 +320,25 @@ public function testRegisterCustomerWithEmailConfirmation(): void
289320
$this->assertEmpty($this->customerRepository->get($email)->getConfirmation());
290321
}
291322

323+
/**
324+
* Email data provider for testing punycode functionality
325+
*
326+
* @return array[]
327+
*/
328+
public static function emailDataProvider(): array
329+
{
330+
return [
331+
'encoded' => [
332+
'email' => '[email protected]',
333+
'expected' => 'test@sómething.com',
334+
],
335+
'non-encoded' => [
336+
'email' => 'test@sómething.com',
337+
'expected' => 'test@sómething.com',
338+
]
339+
];
340+
}
341+
292342
/**
293343
* Fills request with customer data.
294344
*

0 commit comments

Comments
 (0)