Skip to content

Commit 2261550

Browse files
author
Oleksii Korshenko
authored
ENGCOM-861: Fix #13652. Mini cart - fix issue in product title with special chars. #13802
2 parents c7ddedf + 5b7aca1 commit 2261550

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

app/code/Magento/Checkout/CustomerData/DefaultItem.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Checkout\CustomerData;
88

9+
use Magento\Framework\App\ObjectManager;
10+
911
/**
1012
* Default item
1113
*/
@@ -36,26 +38,36 @@ class DefaultItem extends AbstractItem
3638
*/
3739
protected $checkoutHelper;
3840

41+
/**
42+
* Escaper
43+
*
44+
* @var \Magento\Framework\Escaper
45+
*/
46+
private $escaper;
47+
3948
/**
4049
* @param \Magento\Catalog\Helper\Image $imageHelper
4150
* @param \Magento\Msrp\Helper\Data $msrpHelper
4251
* @param \Magento\Framework\UrlInterface $urlBuilder
4352
* @param \Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool
4453
* @param \Magento\Checkout\Helper\Data $checkoutHelper
54+
* @param \Magento\Framework\Escaper|null $escaper
4555
* @codeCoverageIgnore
4656
*/
4757
public function __construct(
4858
\Magento\Catalog\Helper\Image $imageHelper,
4959
\Magento\Msrp\Helper\Data $msrpHelper,
5060
\Magento\Framework\UrlInterface $urlBuilder,
5161
\Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool,
52-
\Magento\Checkout\Helper\Data $checkoutHelper
62+
\Magento\Checkout\Helper\Data $checkoutHelper,
63+
\Magento\Framework\Escaper $escaper = null
5364
) {
5465
$this->configurationPool = $configurationPool;
5566
$this->imageHelper = $imageHelper;
5667
$this->msrpHelper = $msrpHelper;
5768
$this->urlBuilder = $urlBuilder;
5869
$this->checkoutHelper = $checkoutHelper;
70+
$this->escaper = $escaper ?: ObjectManager::getInstance()->get(\Magento\Framework\Escaper::class);
5971
}
6072

6173
/**
@@ -64,14 +76,16 @@ public function __construct(
6476
protected function doGetItemData()
6577
{
6678
$imageHelper = $this->imageHelper->init($this->getProductForThumbnail(), 'mini_cart_product_thumbnail');
79+
$productName = $this->escaper->escapeHtml($this->item->getProduct()->getName());
80+
6781
return [
6882
'options' => $this->getOptionList(),
6983
'qty' => $this->item->getQty() * 1,
7084
'item_id' => $this->item->getId(),
7185
'configure_url' => $this->getConfigureUrl(),
7286
'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(),
7387
'product_id' => $this->item->getProduct()->getId(),
74-
'product_name' => $this->item->getProduct()->getName(),
88+
'product_name' => $productName,
7589
'product_sku' => $this->item->getProduct()->getSku(),
7690
'product_url' => $this->getProductUrl(),
7791
'product_has_url' => $this->hasProductUrl(),

app/code/Magento/Checkout/view/frontend/web/template/minicart/item/default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<div class="product-item-details">
2525
<strong class="product-item-name">
2626
<!-- ko if: product_has_url -->
27-
<a data-bind="attr: {href: product_url}, text: product_name"></a>
27+
<a data-bind="attr: {href: product_url}, html: product_name"></a>
2828
<!-- /ko -->
2929
<!-- ko ifnot: product_has_url -->
3030
<!-- ko text: product_name --><!-- /ko -->

app/code/Magento/ConfigurableProduct/CustomerData/ConfigurableItem.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,24 @@ class ConfigurableItem extends DefaultItem
2626
* @param \Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool
2727
* @param \Magento\Checkout\Helper\Data $checkoutHelper
2828
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
29+
* @param \Magento\Framework\Escaper|null $escaper
2930
*/
3031
public function __construct(
3132
\Magento\Catalog\Helper\Image $imageHelper,
3233
\Magento\Msrp\Helper\Data $msrpHelper,
3334
\Magento\Framework\UrlInterface $urlBuilder,
3435
\Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool,
3536
\Magento\Checkout\Helper\Data $checkoutHelper,
36-
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
37+
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
38+
\Magento\Framework\Escaper $escaper = null
3739
) {
3840
parent::__construct(
3941
$imageHelper,
4042
$msrpHelper,
4143
$urlBuilder,
4244
$configurationPool,
43-
$checkoutHelper
45+
$checkoutHelper,
46+
$escaper
4447
);
4548
$this->_scopeConfig = $scopeConfig;
4649
}

app/code/Magento/GroupedProduct/CustomerData/GroupedItem.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,24 @@ class GroupedItem extends DefaultItem
2222
* @param \Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool
2323
* @param \Magento\Checkout\Helper\Data $checkoutHelper
2424
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
25+
* @param \Magento\Framework\Escaper|null $escaper
2526
*/
2627
public function __construct(
2728
\Magento\Catalog\Helper\Image $imageHelper,
2829
\Magento\Msrp\Helper\Data $msrpHelper,
2930
\Magento\Framework\UrlInterface $urlBuilder,
3031
\Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool,
3132
\Magento\Checkout\Helper\Data $checkoutHelper,
32-
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
33+
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
34+
\Magento\Framework\Escaper $escaper = null
3335
) {
3436
parent::__construct(
3537
$imageHelper,
3638
$msrpHelper,
3739
$urlBuilder,
3840
$configurationPool,
39-
$checkoutHelper
41+
$checkoutHelper,
42+
$escaper
4043
);
4144
$this->_scopeConfig = $scopeConfig;
4245
}

0 commit comments

Comments
 (0)