@@ -70,6 +70,11 @@ class InlineEdit extends \Magento\Backend\App\Action implements HttpPostActionIn
70
70
*/
71
71
private $ addressRegistry ;
72
72
73
+ /**
74
+ * @var \Magento\Framework\Escaper
75
+ */
76
+ private $ escaper ;
77
+
73
78
/**
74
79
* @param Action\Context $context
75
80
* @param CustomerRepositoryInterface $customerRepository
@@ -78,6 +83,7 @@ class InlineEdit extends \Magento\Backend\App\Action implements HttpPostActionIn
78
83
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
79
84
* @param \Psr\Log\LoggerInterface $logger
80
85
* @param AddressRegistry|null $addressRegistry
86
+ * @param \Magento\Framework\Escaper $escaper
81
87
*/
82
88
public function __construct (
83
89
Action \Context $ context ,
@@ -86,14 +92,16 @@ public function __construct(
86
92
\Magento \Customer \Model \Customer \Mapper $ customerMapper ,
87
93
\Magento \Framework \Api \DataObjectHelper $ dataObjectHelper ,
88
94
\Psr \Log \LoggerInterface $ logger ,
89
- AddressRegistry $ addressRegistry = null
95
+ AddressRegistry $ addressRegistry = null ,
96
+ \Magento \Framework \Escaper $ escaper = null
90
97
) {
91
98
$ this ->customerRepository = $ customerRepository ;
92
99
$ this ->resultJsonFactory = $ resultJsonFactory ;
93
100
$ this ->customerMapper = $ customerMapper ;
94
101
$ this ->dataObjectHelper = $ dataObjectHelper ;
95
102
$ this ->logger = $ logger ;
96
103
$ this ->addressRegistry = $ addressRegistry ?: ObjectManager::getInstance ()->get (AddressRegistry::class);
104
+ $ this ->escaper = $ escaper ?: ObjectManager::getInstance ()->get (\Magento \Framework \Escaper::class);
97
105
parent ::__construct ($ context );
98
106
}
99
107
@@ -128,10 +136,14 @@ public function execute()
128
136
129
137
$ postItems = $ this ->getRequest ()->getParam ('items ' , []);
130
138
if (!($ this ->getRequest ()->getParam ('isAjax ' ) && count ($ postItems ))) {
131
- return $ resultJson ->setData ([
132
- 'messages ' => [__ ('Please correct the data sent. ' )],
133
- 'error ' => true ,
134
- ]);
139
+ return $ resultJson ->setData (
140
+ [
141
+ 'messages ' => [
142
+ __ ('Please correct the data sent. ' )
143
+ ],
144
+ 'error ' => true ,
145
+ ]
146
+ );
135
147
}
136
148
137
149
foreach (array_keys ($ postItems ) as $ customerId ) {
@@ -147,10 +159,12 @@ public function execute()
147
159
$ this ->getEmailNotification ()->credentialsChanged ($ this ->getCustomer (), $ currentCustomer ->getEmail ());
148
160
}
149
161
150
- return $ resultJson ->setData ([
151
- 'messages ' => $ this ->getErrorMessages (),
152
- 'error ' => $ this ->isErrorExists ()
153
- ]);
162
+ return $ resultJson ->setData (
163
+ [
164
+ 'messages ' => $ this ->getErrorMessages (),
165
+ 'error ' => $ this ->isErrorExists ()
166
+ ]
167
+ );
154
168
}
155
169
156
170
/**
@@ -234,13 +248,16 @@ protected function saveCustomer(CustomerInterface $customer)
234
248
$ this ->disableAddressValidation ($ customer );
235
249
$ this ->customerRepository ->save ($ customer );
236
250
} catch (\Magento \Framework \Exception \InputException $ e ) {
237
- $ this ->getMessageManager ()->addError ($ this ->getErrorWithCustomerId ($ e ->getMessage ()));
251
+ $ this ->getMessageManager ()
252
+ ->addError ($ this ->getErrorWithCustomerId ($ this ->escaper ->escapeHtml ($ e ->getMessage ())));
238
253
$ this ->logger ->critical ($ e );
239
254
} catch (\Magento \Framework \Exception \LocalizedException $ e ) {
240
- $ this ->getMessageManager ()->addError ($ this ->getErrorWithCustomerId ($ e ->getMessage ()));
255
+ $ this ->getMessageManager ()
256
+ ->addError ($ this ->getErrorWithCustomerId ($ this ->escaper ->escapeHtml ($ e ->getMessage ())));
241
257
$ this ->logger ->critical ($ e );
242
258
} catch (\Exception $ e ) {
243
- $ this ->getMessageManager ()->addError ($ this ->getErrorWithCustomerId ('We can \'t save the customer. ' ));
259
+ $ this ->getMessageManager ()
260
+ ->addError ($ this ->getErrorWithCustomerId ('We can \'t save the customer. ' ));
244
261
$ this ->logger ->critical ($ e );
245
262
}
246
263
}
0 commit comments