Skip to content

Commit 9df9db2

Browse files
committed
Fix issue product name render wrong with special characters
update update update update up up up update up Update default.html fix getProductNameUnsanitizedHtml is not defined up
1 parent b9c13fd commit 9df9db2

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</item>
2222
<item name="children" xsi:type="array">
2323
<item name="item.renderer" xsi:type="array">
24-
<item name="component" xsi:type="string">uiComponent</item>
24+
<item name="component" xsi:type="string">Magento_Checkout/js/view/cart-item-renderer</item>
2525
<item name="config" xsi:type="array">
2626
<item name="displayArea" xsi:type="string">defaultRenderer</item>
2727
<item name="template" xsi:type="string">Magento_Checkout/minicart/item/default</item>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'uiComponent'
8+
], function (Component) {
9+
'use strict';
10+
11+
return Component.extend({
12+
/**
13+
* Prepare the product name value to be rendered as HTML
14+
*
15+
* @param {String} productName
16+
* @return {String}
17+
*/
18+
getProductNameUnsanitizedHtml: function (productName) {
19+
// product name has already escaped on backend
20+
return productName;
21+
},
22+
23+
/**
24+
* Prepare the given option value to be rendered as HTML
25+
*
26+
* @param {String} optionValue
27+
* @return {String}
28+
*/
29+
getOptionValueUnsanitizedHtml: function (optionValue) {
30+
// option value has already escaped on backend
31+
return optionValue;
32+
}
33+
});
34+
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
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}, html: product_name"></a>
27+
<a data-bind="attr: {href: product_url}, html: $parent.getProductNameUnsanitizedHtml(product_name)"></a>
2828
<!-- /ko -->
2929
<!-- ko ifnot: product_has_url -->
30-
<!-- ko text: product_name --><!-- /ko -->
30+
<span data-bind="html: $parent.getProductNameUnsanitizedHtml(product_name)"></span>
3131
<!-- /ko -->
3232
</strong>
3333

@@ -42,10 +42,10 @@
4242
<dt class="label"><!-- ko text: option.label --><!-- /ko --></dt>
4343
<dd class="values">
4444
<!-- ko if: Array.isArray(option.value) -->
45-
<span data-bind="html: option.value.join('<br>')"></span>
45+
<span data-bind="html: $parents[1].getOptionValueUnsanitizedHtml(option.value.join('<br/>'))"></span>
4646
<!-- /ko -->
4747
<!-- ko if: (!Array.isArray(option.value) && ['file', 'html'].includes(option.option_type)) -->
48-
<span data-bind="html: option.value"></span>
48+
<span data-bind="html: $parents[1].getOptionValueUnsanitizedHtml(option.value)"></span>
4949
<!-- /ko -->
5050
<!-- ko if: (!Array.isArray(option.value) && !['file', 'html'].includes(option.option_type)) -->
5151
<span data-bind="text: option.value"></span>

0 commit comments

Comments
 (0)