" in the title, e.g. My Product - 19" x 16" Header" in product nameSyntaxError: Unexpected token x in JSONMagento_Catalog view/frontend/templates/product/breadcrumbs.phtml:
<div class="breadcrumbs" data-mage-init='{
"breadcrumbs": {
"categoryUrlSuffix": "<?= $block->escapeHtml($viewModel->getCategoryUrlSuffix()); ?>",
"useCategoryPathInUrl": <?= (int)$viewModel->isCategoryUsedInProductUrl(); ?>,
"product": "<?= $block->escapeHtml($viewModel->getProductName()); ?>"
}
}'>
</div>
To fix the issue, the product name value must go through $block->escapeJs()
I have the same issue here (also 2.2.4). I'll quick fix it for now (thanks @brian-labelle), but this definitely needs to be fixed.
We have the same issue, is there any fix for this already?
@Bobstar040 : my best guess would be to implement the fix as described by @brian-labelle at the moment. I hope that this will be fixed in M2.2.5+ / M2.3, but probably @magento-engcom-team could shed more light on this.
Same issue here too with hundreds of products that contain quotes. I'll implement @brian-labelle 's fix.
Nice detailed fix: https://magento.stackexchange.com/q/224587/52084
@magento-engcom-team unable to re-produce the issue in 2.2-develop branch, magento version 2.2.6-dev.
#dmcdindia
I am working on this at #dmcdindia
Hi @brian-labelle. Thank you for your report.
The issue has been fixed in magento/magento2#15347 by @jignesh-baldha in 2.2-develop branch
Related commit(s):
The fix will be available with the upcoming 2.2.5 release.
Hi @brian-labelle. Thank you for your report.
The issue has been fixed in magento/magento2#16148 by @jignesh-baldha in 2.3-develop branch
Related commit(s):
The fix will be available with the upcoming 2.3.0 release.
Since @magento-engcom-team have not implemented this in 2.5.5... For anyone else who needs it, to implement the fix described by @brian-labelle in a theme.
cp app/code/Magento/Catalog/view/frontend/templates/product/breadcrumbs.phtml app/design/frontend/<vendor>/<theme>/Magento_Catalog/templates/product/
then edit
"product": "<?= $block->escapeHtml($viewModel->getProductName()); ?>"
to
"product": "<?= $block->escapeJs($viewModel->getProductName()); ?>"
then clear your cache.
You have to overwrite the file app/design/frontend/Vendor/Theme/Magento_Catalog/templates/product/breadcrumbs.phtml
then edit
"product": "= $block->escapeHtml($viewModel->getProductName()); ?>"
to
"product": "product": "= $block->escapeHtml($block->escapeJsQuote($viewModel->getProductName(), '"')); ?>"
then clear your cache.
Most helpful comment
I have the same issue here (also 2.2.4). I'll quick fix it for now (thanks @brian-labelle), but this definitely needs to be fixed.