File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
lib/internal/Magento/Framework Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -303,11 +303,12 @@ public function encodeUrlParam($string)
303
303
*/
304
304
public function escapeJs ($ string )
305
305
{
306
- if (!is_string ($ string ) && ! is_array ( $ string ) ) {
306
+ if (!is_string ($ string )) {
307
307
// In PHP > 8, preg_replace_callback throws an error if the 3rd param type is incorrect.
308
308
// This check emulates an old behavior.
309
- return $ string ;
309
+ $ string = ( string ) $ string ;
310
310
}
311
+
311
312
if ($ string === '' || ctype_digit ($ string )) {
312
313
return $ string ;
313
314
}
Original file line number Diff line number Diff line change @@ -137,6 +137,8 @@ public function escapeJsDataProvider()
137
137
{
138
138
return [
139
139
'zero length string ' => ['' , '' ],
140
+ 'null as string ' => [null , '' ],
141
+ 'Magento\Framework\Phrase as string ' => [__ ('test ' ), 'test ' ],
140
142
'only digits ' => ['123 ' , '123 ' ],
141
143
'< ' => ['< ' , '\u003C ' ],
142
144
'> ' => ['> ' , '\\u003E ' ],
You can’t perform that action at this time.
0 commit comments