Skip to content

Commit 5d114e0

Browse files
author
Roman Leshchenko
committed
MAGETWO-93150: Fixed incorrect behavior of customer form
1 parent 578738a commit 5d114e0

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Framework\Exception\InputException;
2121
use Magento\Framework\Exception\InvalidEmailOrPasswordException;
2222
use Magento\Framework\Exception\State\UserLockedException;
23+
use Magento\Framework\Escaper;
2324

2425
/**
2526
* Class EditPost
@@ -70,28 +71,34 @@ class EditPost extends \Magento\Customer\Controller\AbstractAccount
7071
*/
7172
private $customerMapper;
7273

74+
/** @var Escaper */
75+
private $escaper;
76+
7377
/**
7478
* @param Context $context
7579
* @param Session $customerSession
7680
* @param AccountManagementInterface $customerAccountManagement
7781
* @param CustomerRepositoryInterface $customerRepository
7882
* @param Validator $formKeyValidator
7983
* @param CustomerExtractor $customerExtractor
84+
* @param Escaper|null $escaper
8085
*/
8186
public function __construct(
8287
Context $context,
8388
Session $customerSession,
8489
AccountManagementInterface $customerAccountManagement,
8590
CustomerRepositoryInterface $customerRepository,
8691
Validator $formKeyValidator,
87-
CustomerExtractor $customerExtractor
92+
CustomerExtractor $customerExtractor,
93+
Escaper $escaper = null
8894
) {
8995
parent::__construct($context);
9096
$this->session = $customerSession;
9197
$this->customerAccountManagement = $customerAccountManagement;
9298
$this->customerRepository = $customerRepository;
9399
$this->formKeyValidator = $formKeyValidator;
94100
$this->customerExtractor = $customerExtractor;
101+
$this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class);
95102
}
96103

97104
/**
@@ -173,9 +180,9 @@ public function execute()
173180
$this->messageManager->addError($message);
174181
return $resultRedirect->setPath('customer/account/login');
175182
} catch (InputException $e) {
176-
$this->messageManager->addError($e->getMessage());
183+
$this->messageManager->addErrorMessage($this->escaper->escapeHtml($e->getMessage()));
177184
foreach ($e->getErrors() as $error) {
178-
$this->messageManager->addError($error->getMessage());
185+
$this->messageManager->addErrorMessage($this->escaper->escapeHtml($error->getMessage()));
179186
}
180187
} catch (\Magento\Framework\Exception\LocalizedException $e) {
181188
$this->messageManager->addError($e->getMessage());

dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ public function testMissingDataEditPostAction()
565565

566566
$this->assertRedirect($this->stringEndsWith('customer/account/edit/'));
567567
$this->assertSessionMessages(
568-
$this->equalTo(['"Email" is not a valid email address.']),
568+
$this->equalTo(['"Email" is not a valid email address.']),
569569
MessageInterface::TYPE_ERROR
570570
);
571571
}
@@ -622,7 +622,7 @@ public function testWrongConfirmationEditPostAction()
622622

623623
$this->assertRedirect($this->stringEndsWith('customer/account/edit/'));
624624
$this->assertSessionMessages(
625-
$this->equalTo(['Password confirmation doesn\'t match entered password.']),
625+
$this->equalTo(['Password confirmation doesn't match entered password.']),
626626
MessageInterface::TYPE_ERROR
627627
);
628628
}

0 commit comments

Comments
 (0)