Skip to content

Commit 076d199

Browse files
authored
Merge pull request #1131 from magento-fearless-kiwis/FearlessKiwis-MAGETWO-67496
[fearless] MAGETWO-67496: Quotes in Product name causes JSON Error on Product Page on Storefront when Display Actual Price set to "On Gesture"
2 parents 86794cb + 1d2eaac commit 076d199

File tree

5 files changed

+87
-7
lines changed

5 files changed

+87
-7
lines changed

app/code/Magento/Msrp/view/base/templates/product/price/msrp.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ if ($product->isSaleable()) {
5656
$data = ['addToCart' => [
5757
'origin'=> 'msrp',
5858
'popupId' => '#' . $popupId,
59-
'productName' => $product->getName(),
59+
'productName' => $block->escapeJs($block->escapeHtml($product->getName())),
6060
'productId' => $productId,
6161
'productIdInput' => 'input[type="hidden"][name="product"]',
6262
'realPrice' => $block->getRealPriceHtml(),
@@ -80,7 +80,7 @@ if ($product->isSaleable()) {
8080
<a href="javascript:void(0);"
8181
id="<?php /* @escapeNotVerified */ echo($popupId);?>"
8282
class="action map-show-info"
83-
data-mage-init='<?= /* @escapeNotVerified */ $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($data)?>'><?php /* @escapeNotVerified */ echo __('Click for price'); ?>
83+
data-mage-init='<?= /* @noEscape */ $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($data)?>'><?php /* @escapeNotVerified */ echo __('Click for price'); ?>
8484
</a>
8585
<?php else: ?>
8686
<span class="msrp-message">

app/code/Magento/Msrp/view/frontend/templates/render/item/price_msrp_item.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<a href="javascript:void(0);"
3939
id="<?php /* @escapeNotVerified */ echo($popupId);?>"
4040
data-mage-init='{"addToCart":{"popupId": "#<?php /* @escapeNotVerified */ echo($popupId);?>",
41-
"productName": "<?php /* @escapeNotVerified */ echo $_product->getName() ?>",
41+
"productName": "<?php /* @noEscape */ echo $block->escapeJs($block->escapeHtml($_product->getName())) ?>",
4242
"realPrice": <?php /* @escapeNotVerified */ echo $block->getRealPriceJs($_product) ?>,
4343
"msrpPrice": "<?php /* @escapeNotVerified */ echo $_msrpPrice ?>",
4444
"priceElementId":"<?php /* @escapeNotVerified */ echo $priceElementId ?>",
@@ -51,5 +51,5 @@
5151
</span>
5252
<?php endif; ?>
5353
<?php $helpLinkId = 'msrp-help-' . $_id . $block->getRandomString(20); ?>
54-
<a href="javascript:void(0);" id="<?php /* @escapeNotVerified */ echo($helpLinkId);?>" data-mage-init='{"addToCart":{"helpLinkId": "#<?php /* @escapeNotVerified */ echo($helpLinkId);?>", "productName": "<?php /* @escapeNotVerified */ echo $_product->getName() ?>"}}' class="link tip"><?php /* @escapeNotVerified */ echo __("What's this?"); ?></a>
54+
<a href="javascript:void(0);" id="<?php /* @escapeNotVerified */ echo($helpLinkId);?>" data-mage-init='{"addToCart":{"helpLinkId": "#<?php /* @escapeNotVerified */ echo($helpLinkId);?>", "productName": "<?php /* @noEscape */ echo $block->escapeJs($block->escapeHtml($_product->getName())) ?>"}}' class="link tip"><?php /* @escapeNotVerified */ echo __("What's this?"); ?></a>
5555
</div>

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
<constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertProductTierPriceOnProductPage" />
171171
</variation>
172172
<variation name="CreateConfigurableProductEntityTestVariation11" summary="Create Configurable Product with out of stock child" ticketId="MAGETWO-65660">
173-
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test</data>
173+
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, stable:no</data>
174174
<data name="product/data/configurable_attributes_data/dataset" xsi:type="string">with_out_of_stock_item</data>
175175
<data name="product/data/name" xsi:type="string">Configurable Product %isolation%</data>
176176
<data name="product/data/sku" xsi:type="string">configurable_sku_%isolation%</data>
@@ -188,7 +188,7 @@
188188
<constraint name="Magento\Catalog\Test\Constraint\AssertProductVisibleInCategory" />
189189
</variation>
190190
<variation name="CreateConfigurableProductEntityTestVariation12" summary="Create Configurable Product with disabled child" ticketId="MAGETWO-65661">
191-
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test</data>
191+
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, stable:no</data>
192192
<data name="product/data/configurable_attributes_data/dataset" xsi:type="string">with_disabled_item</data>
193193
<data name="product/data/name" xsi:type="string">Configurable Product %isolation%</data>
194194
<data name="product/data/sku" xsi:type="string">configurable_sku_%isolation%</data>
@@ -206,7 +206,7 @@
206206
<constraint name="Magento\Catalog\Test\Constraint\AssertProductNotVisibleInCategory" />
207207
</variation>
208208
<variation name="CreateConfigurableProductEntityTestVariation13" summary="Create Configurable Product with one disabled child and with one out of stock child" ticketId="MAGETWO-65662">
209-
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test</data>
209+
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, stable:no</data>
210210
<data name="product/data/configurable_attributes_data/dataset" xsi:type="string">with_one_disabled_item_and_one_out_of_stock_item</data>
211211
<data name="product/data/name" xsi:type="string">Configurable Product %isolation%</data>
212212
<data name="product/data/sku" xsi:type="string">configurable_sku_%isolation%</data>

dev/tests/functional/tests/app/Magento/Msrp/Test/Repository/CatalogProductSimple.xml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,69 @@
102102
<field name="msrp" xsi:type="string">15</field>
103103
<field name="msrp_display_actual_price_type" xsi:type="string">In Cart</field>
104104
</dataset>
105+
106+
<dataset name="msrp_on_gesture_for_product_with_single_quotes_in_product_name">
107+
<field name="name" xsi:type="string">\'Simple Product with\' msrp on gesture %isolation%</field>
108+
<field name="url_key" xsi:type="string">simple-product-with-msrp on gesture-%isolation%</field>
109+
<field name="sku" xsi:type="string">sku_simple_product_with_msrp_on_gesture_%isolation%</field>
110+
<field name="weight" xsi:type="string">1</field>
111+
<field name="product_has_weight" xsi:type="string">This item has weight</field>
112+
<field name="quantity_and_stock_status" xsi:type="array">
113+
<item name="qty" xsi:type="string">1000</item>
114+
<item name="is_in_stock" xsi:type="string">In Stock</item>
115+
</field>
116+
<field name="price" xsi:type="array">
117+
<item name="value" xsi:type="string">20</item>
118+
<item name="dataset" xsi:type="string">-</item>
119+
</field>
120+
<field name="category_ids" xsi:type="array">
121+
<item name="dataset" xsi:type="string">default_subcategory</item>
122+
</field>
123+
<field name="tax_class_id" xsi:type="array">
124+
<item name="dataset" xsi:type="string">taxable_goods</item>
125+
</field>
126+
<field name="website_ids" xsi:type="array">
127+
<item name="0" xsi:type="array">
128+
<item name="dataset" xsi:type="string">default</item>
129+
</item>
130+
</field>
131+
<field name="stock_data" xsi:type="array">
132+
<item name="manage_stock" xsi:type="string">No</item>
133+
</field>
134+
<field name="msrp" xsi:type="string">35</field>
135+
<field name="msrp_display_actual_price_type" xsi:type="string">On Gesture</field>
136+
</dataset>
137+
138+
<dataset name="msrp_on_gesture_for_product_with_one_single_quote_in_product_name">
139+
<field name="name" xsi:type="string">\'Simple Product with msrp on gesture %isolation%</field>
140+
<field name="url_key" xsi:type="string">simple-product-with-msrp on gesture-%isolation%</field>
141+
<field name="sku" xsi:type="string">sku_simple_product_with_msrp_on_gesture_%isolation%</field>
142+
<field name="weight" xsi:type="string">1</field>
143+
<field name="product_has_weight" xsi:type="string">This item has weight</field>
144+
<field name="quantity_and_stock_status" xsi:type="array">
145+
<item name="qty" xsi:type="string">1000</item>
146+
<item name="is_in_stock" xsi:type="string">In Stock</item>
147+
</field>
148+
<field name="price" xsi:type="array">
149+
<item name="value" xsi:type="string">20</item>
150+
<item name="dataset" xsi:type="string">-</item>
151+
</field>
152+
<field name="category_ids" xsi:type="array">
153+
<item name="dataset" xsi:type="string">default_subcategory</item>
154+
</field>
155+
<field name="tax_class_id" xsi:type="array">
156+
<item name="dataset" xsi:type="string">taxable_goods</item>
157+
</field>
158+
<field name="website_ids" xsi:type="array">
159+
<item name="0" xsi:type="array">
160+
<item name="dataset" xsi:type="string">default</item>
161+
</item>
162+
</field>
163+
<field name="stock_data" xsi:type="array">
164+
<item name="manage_stock" xsi:type="string">No</item>
165+
</field>
166+
<field name="msrp" xsi:type="string">35</field>
167+
<field name="msrp_display_actual_price_type" xsi:type="string">On Gesture</field>
168+
</dataset>
105169
</repository>
106170
</config>

dev/tests/functional/tests/app/Magento/Msrp/Test/TestCase/ApplyMapTest.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,21 @@
3030
<constraint name="Magento\Msrp\Test\Constraint\AssertMsrpOnProductView" />
3131
<constraint name="Magento\Msrp\Test\Constraint\AssertMsrpInShoppingCart" />
3232
</variation>
33+
<variation name="ApplyMapTestVariation4" summary="Apply MAP Setting on Gesture to Simple Product with Quotes in product name" ticketId="MAGETWO-69318">
34+
<data name="product" xsi:type="string">catalogProductSimple::msrp_on_gesture_for_product_with_single_quotes_in_product_name</data>
35+
<constraint name="Magento\Msrp\Test\Constraint\AssertMsrpOnCategoryPage" />
36+
<constraint name="Magento\Msrp\Test\Constraint\AssertMapOnCategoryPage" />
37+
<constraint name="Magento\Msrp\Test\Constraint\AssertMsrpOnProductView" />
38+
<constraint name="Magento\Msrp\Test\Constraint\AssertMapOnProductView" />
39+
<constraint name="Magento\Msrp\Test\Constraint\AssertMsrpInShoppingCart" />
40+
</variation>
41+
<variation name="ApplyMapTestVariation5" summary="Apply MAP Setting on Gesture to Simple Product with Quotes in product name" ticketId="MAGETWO-69318">
42+
<data name="product" xsi:type="string">catalogProductSimple::msrp_on_gesture_for_product_with_one_single_quote_in_product_name</data>
43+
<constraint name="Magento\Msrp\Test\Constraint\AssertMsrpOnCategoryPage" />
44+
<constraint name="Magento\Msrp\Test\Constraint\AssertMapOnCategoryPage" />
45+
<constraint name="Magento\Msrp\Test\Constraint\AssertMsrpOnProductView" />
46+
<constraint name="Magento\Msrp\Test\Constraint\AssertMapOnProductView" />
47+
<constraint name="Magento\Msrp\Test\Constraint\AssertMsrpInShoppingCart" />
48+
</variation>
3349
</testCase>
3450
</config>

0 commit comments

Comments
 (0)