|
20 | 20 | use Magento\Framework\Exception\InputException; |
21 | 21 | use Magento\Framework\Exception\InvalidEmailOrPasswordException; |
22 | 22 | use Magento\Framework\Exception\State\UserLockedException; |
| 23 | +use Magento\Framework\Escaper; |
23 | 24 |
|
24 | 25 | /** |
25 | 26 | * Class EditPost |
@@ -70,28 +71,34 @@ class EditPost extends \Magento\Customer\Controller\AbstractAccount |
70 | 71 | */ |
71 | 72 | private $customerMapper; |
72 | 73 |
|
| 74 | + /** @var Escaper */ |
| 75 | + private $escaper; |
| 76 | + |
73 | 77 | /** |
74 | 78 | * @param Context $context |
75 | 79 | * @param Session $customerSession |
76 | 80 | * @param AccountManagementInterface $customerAccountManagement |
77 | 81 | * @param CustomerRepositoryInterface $customerRepository |
78 | 82 | * @param Validator $formKeyValidator |
79 | 83 | * @param CustomerExtractor $customerExtractor |
| 84 | + * @param Escaper|null $escaper |
80 | 85 | */ |
81 | 86 | public function __construct( |
82 | 87 | Context $context, |
83 | 88 | Session $customerSession, |
84 | 89 | AccountManagementInterface $customerAccountManagement, |
85 | 90 | CustomerRepositoryInterface $customerRepository, |
86 | 91 | Validator $formKeyValidator, |
87 | | - CustomerExtractor $customerExtractor |
| 92 | + CustomerExtractor $customerExtractor, |
| 93 | + Escaper $escaper = null |
88 | 94 | ) { |
89 | 95 | parent::__construct($context); |
90 | 96 | $this->session = $customerSession; |
91 | 97 | $this->customerAccountManagement = $customerAccountManagement; |
92 | 98 | $this->customerRepository = $customerRepository; |
93 | 99 | $this->formKeyValidator = $formKeyValidator; |
94 | 100 | $this->customerExtractor = $customerExtractor; |
| 101 | + $this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class); |
95 | 102 | } |
96 | 103 |
|
97 | 104 | /** |
@@ -173,9 +180,9 @@ public function execute() |
173 | 180 | $this->messageManager->addError($message); |
174 | 181 | return $resultRedirect->setPath('customer/account/login'); |
175 | 182 | } catch (InputException $e) { |
176 | | - $this->messageManager->addError($e->getMessage()); |
| 183 | + $this->messageManager->addErrorMessage($this->escaper->escapeHtml($e->getMessage())); |
177 | 184 | foreach ($e->getErrors() as $error) { |
178 | | - $this->messageManager->addError($error->getMessage()); |
| 185 | + $this->messageManager->addErrorMessage($this->escaper->escapeHtml($error->getMessage())); |
179 | 186 | } |
180 | 187 | } catch (\Magento\Framework\Exception\LocalizedException $e) { |
181 | 188 | $this->messageManager->addError($e->getMessage()); |
|
0 commit comments