magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Quotes in product name causes JSON error on product page MAP What's This Popup #8059

Closed justenpeters closed 7 years ago

justenpeters commented 7 years ago

Preconditions

  1. Magento 2.1.2

Steps to reproduce

  1. Include single quote ( ' ) or double quote ( " ) in product name
  2. Add an MSRP price
  3. View product page

Expected result

  1. Popup opens as expected

Actual result

  1. Unexpected end of JSON input error screen shot 2017-01-05 at 4 30 32 pm screen shot 2017-01-05 at 4 37 36 pm
veloraven commented 7 years ago

@justenpeters thank you for your report. I have created internal ticket for it: MAGETWO-63116

okorshenko commented 7 years ago

Backport ticket for 2.1-develop: MAGETWO-69708

magento-engcom-team commented 7 years ago

@justenpeters thank you for your report. The fix for this issue is already available in release 2.2.0

harrigo commented 6 years ago

This issue seems to have resurfaced for me in Magento 2.2.4. Was not an issue in 2.2.3. Have fixed by formatting html characters in product name for breadcrumbs.phtml within Catalog module.

genyuk commented 6 years ago

Same issue appeared in 2.2.4. @harrigo - Could you please provide the fix you applied to breadcrumbs.phtml file?

davidverholen commented 6 years ago

as a workaround you can change the template in your custom theme

magento/vendor/magento/module-catalog/view/frontend/templates/product/breadcrumbs.phtml

<?php
/** @var \Magento\Theme\Block\Html\Breadcrumbs $block */
/** @var \Magento\Catalog\ViewModel\Product\Breadcrumbs $viewModel */
$viewModel = $block->getData('viewModel');
$breadCrumbConfig = [
    'breadcrumbs' => [
        'categoryUrlSuffix' => $block->escapeHtml($viewModel->getCategoryUrlSuffix()),
        'useCategoryPathInUrl' => (int)$viewModel->isCategoryUsedInProductUrl(),
        'product' => $viewModel->getProductName()
    ]
]
?>
<div class="breadcrumbs" data-mage-init='<?= $block->escapeHtml(json_encode($breadCrumbConfig)) ?>'></div>

however the correct way to to do it would be creating the json config in the \Magento\Catalog\ViewModel\Product\Breadcrumbs View Model and use the internal json serializer I think

EmilyPepperman commented 6 years ago

Issue is there in Magento 2.2.5 !!!!

zakgrindle commented 6 years ago

This issue also breaks Widget conditions in the admin panel if categories have an & in the name

inkobject commented 6 years ago

Seeing this issue in 2.2.5 In my use case, I sell plants. Double and single quotes have a definite meaning in naming conventions: species, hybrids, cultivars etc. Not being able to use double quotes makes things problematic for me.

aeu commented 6 years ago

I am also seeing this in 2.2.5

aeu commented 6 years ago

@inkobject I have the same problem as you, we sell products that are measured in feet and inches. I was able to work around this by using the Prime and Double Prime Symbols in my product names.

https://en.wikipedia.org/wiki/Prime_(symbol)

Kind of ridiculous that I had to do this, but on the other hand using the Prime symbols is typographically more correct.

hostep commented 6 years ago

For the people reporting the issue in Magento 2.2.4 and 2.2.5, it's not the exact same issue as the original issue. Maybe better to watch these issues: https://github.com/magento/magento2/issues/15037 & https://github.com/magento/magento2/issues/15268 & https://github.com/magento/magento2/issues/15491 & https://github.com/magento/magento2/issues/15631 & https://github.com/magento/magento2/issues/17967

The real fix is in here: https://github.com/magento/magento2/pull/15521, but that one can't be applied cleanly to Magento 2.2.5. You can find a patch which you can apply cleanly to 2.2.5 in https://github.com/magento/magento2/issues/15631#issuecomment-419523038

Or you can wait for Magento 2.2.6, it should normally also contain the fix. Release date is supposed to be somewhere next week, or maybe the week after (but don't take my word for it).

nike1994 commented 1 year ago

I have the same problem In Magento 2.4.6 :/

hostep commented 1 year ago

@nike1994: if you can reproduce it on a clean installation, please open a new issue with steps of how to reproduce it. It won't help with commenting on a 5 year old issue, it's most likely a different problem.