Skip to content

Commit d514bfc

Browse files
authored
Merge pull request #19 from mageplaza/2.4-develop
- Compatible with Magento v2.3.6 - Fixed XSS bugs
2 parents e36aaaa + 419c635 commit d514bfc

File tree

2 files changed

+2
-30
lines changed

2 files changed

+2
-30
lines changed

Helper/Data.php

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function getLayerConfiguration($filters)
5757
if ($key === 'amp;dimbaar') {
5858
continue;
5959
}
60-
$filterParams[$this->escapeJs(htmlentities($key))] = $this->escapeJs(htmlentities($param));
60+
$filterParams[htmlentities($key)] = htmlentities($param);
6161
}
6262
$config = new DataObject([
6363
'active' => array_keys($filterParams),
@@ -67,32 +67,4 @@ public function getLayerConfiguration($filters)
6767

6868
return self::jsonEncode($config->getData());
6969
}
70-
71-
/**
72-
* from Magento Core
73-
*
74-
* @param string $string
75-
*
76-
* @return string|null
77-
*/
78-
public function escapeJs($string)
79-
{
80-
if ($string === '' || ctype_digit($string)) {
81-
return $string;
82-
}
83-
84-
return preg_replace_callback(
85-
'/[^a-z0-9,\._]/iSu',
86-
function ($matches) {
87-
$chr = $matches[0];
88-
if (strlen($chr) != 1) {
89-
$chr = mb_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
90-
$chr = ($chr === false) ? '' : $chr;
91-
}
92-
93-
return sprintf('\\u%04s', strtoupper(bin2hex($chr)));
94-
},
95-
$string
96-
);
97-
}
9870
}

view/frontend/templates/layer/view.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<script type="text/x-magento-init">
8080
{
8181
".block-content.filter-content":{
82-
"mpAjax": <?= /** @noEscape */ $layerConfig ?>
82+
"mpAjax": <?= /** @noEscape */ $block->escapeJs($layerConfig) ?>
8383
}
8484
}
8585
</script>

0 commit comments

Comments
 (0)