Skip to content

Commit a68f154

Browse files
authored
Merge pull request #288 from hostep/fixes-incorrect-escaping-methods-used
Fixes some more wrong escaping methods being used in frontend files.
2 parents 56b6fdd + 0219243 commit a68f154

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

view/frontend/templates/hyva/script-product-clicks.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $productPath = $block->getProductPath();
2929
return yireoGoogleTagManager2FindParentElementWithName(element.parentElement, parentTagName);
3030
}
3131

32-
const products = document.querySelectorAll('<?= $escaper->escapeHtml($productPath) ?>');
32+
const products = document.querySelectorAll('<?= $escaper->escapeJs($productPath) ?>');
3333
if (products && products.length > 0) {
3434
products.forEach(function(product) {
3535
product.addEventListener('click', function(event, s) {

view/frontend/templates/iframe.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ use Yireo\GoogleTagManager2\Config\Config;
88
/** @var Config $config */
99
/** @var Template $block */
1010
$config = $block->getConfig();
11+
$url = sprintf('%s/ns.html?id=%s', $config->getGoogleTagmanagerUrl(), $config->getId());
1112
?>
12-
<noscript><iframe src="<?= $escaper->escapeUrl($config->getGoogleTagmanagerUrl()) ?>/ns.html?id=<?= $escaper->escapeHtml($config->getId()) ?>" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
13+
<noscript><iframe src="<?= $escaper->escapeUrl($url) ?>" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>

view/frontend/templates/luma/script-product-clicks.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ $productPath = $block->getProductPath();
1717
?>
1818
<script>
1919
require(['yireoGoogleTagManagerProductClicks'], function(clicks) {
20-
clicks({productPath: '<?= $escaper->escapeHtml($productPath) ?>'});
20+
clicks({productPath: '<?= $escaper->escapeJs($productPath) ?>'});
2121
});
2222
</script>

view/frontend/templates/product/details.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ $product = $productDetails->getProduct();
2121
$productData = $dataLayer->toJson($productDetails->merge());
2222
?>
2323
<script>
24-
window['YIREO_GOOGLETAGMANAGER2_PRODUCT_DATA_ID_<?= $escaper->escapeHtml($product->getId()) ?>'] = <?= /* @noEscape */ $productData ?>;
24+
window['YIREO_GOOGLETAGMANAGER2_PRODUCT_DATA_ID_<?= $escaper->escapeJs($product->getId()) ?>'] = <?= /* @noEscape */ $productData ?>;
2525
</script>

view/frontend/templates/script.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ $events = ($config->waitForUserInteraction() === false)
3232
j = d.createElement(s),
3333
dl = l != 'dataLayer' ? '&l=' + l : '';
3434
j.async = true;
35-
j.src = '<?= $escaper->escapeUrl($config->getGoogleTagmanagerUrl()) ?>' + '/gtm.js?id=' + i + dl;
35+
j.src = '<?= $escaper->escapeJs($config->getGoogleTagmanagerUrl()) ?>' + '/gtm.js?id=' + i + dl;
3636
f.parentNode.insertBefore(j, f);
37-
})(window, document, 'script', 'dataLayer', '<?= $escaper->escapeHtml($gtmId) ?>');
37+
})(window, document, 'script', 'dataLayer', '<?= $escaper->escapeJs($gtmId) ?>');
3838
<?php endforeach; ?>
3939
};
4040

0 commit comments

Comments
 (0)