Skip to content

Chore: Wishlist - Replace Block Escaping with Escaper #37042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line above copyright


/** @var \Magento\Framework\View\Element\Template $block */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>
<?php $scriptString = <<<script
use Magento\Framework\Escaper;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Helper\SecureHtmlRenderer;

/** @var Escaper $escaper */
/** @var Template $block */
/** @var SecureHtmlRenderer $secureRenderer */

$scriptString = <<<script

require([
"Magento_Ui/js/modal/confirm",
Expand All @@ -21,14 +27,14 @@
if (!urlParams) {
urlParams = '';
}
var url = {$block->escapeJs($block->getJsObjectName())}.url + '?ajax=true' + urlParams;
var url = {$escaper->escapeJs($block->getJsObjectName())}.url + '?ajax=true' + urlParams;
new Ajax.Updater(
{$block->escapeJs($block->getJsObjectName())}.containerId,
{$escaper->escapeJs($block->getJsObjectName())}.containerId,
url,
{
parameters: {form_key: FORM_KEY},
onComplete: {$block->escapeJs($block->getJsObjectName())}.initGrid
.bind({$block->escapeJs($block->getJsObjectName())}),
onComplete: {$escaper->escapeJs($block->getJsObjectName())}.initGrid
.bind({$escaper->escapeJs($block->getJsObjectName())}),
evalScripts:true
}
);
Expand All @@ -51,7 +57,7 @@
var self = this;

confirm({
content: '{$block->escapeJs(__('Are you sure you want to remove this item?'))}',
content: '{$escaper->escapeJs(__('Are you sure you want to remove this item?'))}',
actions: {
confirm: function () {
self.reload('&delete=' + itemId);
Expand All @@ -64,8 +70,8 @@
productConfigure.addListType(
'wishlist',
{
urlFetch: '{$block->escapeJs($block->getUrl('customer/wishlist_product_composite_wishlist/configure'))}',
urlConfirm: '{$block->escapeJs($block->getUrl('customer/wishlist_product_composite_wishlist/update'))}'
urlFetch: '{$escaper->escapeJs($block->getUrl('customer/wishlist_product_composite_wishlist/configure'))}',
urlConfirm: '{$escaper->escapeJs($block->getUrl('customer/wishlist_product_composite_wishlist/update'))}'
}
);
//-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php
/** @var \Magento\Catalog\Pricing\Render\ConfiguredPriceBox $block */
declare(strict_types=1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line above copyright


use Magento\Catalog\Pricing\Render\ConfiguredPriceBox;
use Magento\Framework\Escaper;

/** @var Escaper $escaper */
/** @var ConfiguredPriceBox $block */
$schema = ($block->getZone() == 'item_view');
$idSuffix = $block->getIdSuffix() ?: '';
?>
Expand All @@ -15,8 +19,8 @@ $idSuffix = $block->getIdSuffix() ?: '';
<?= /* @noEscape */ $block->renderAmount(
$block->getConfiguredPrice()->getAmount(),
[
'display_label' => $block->escapeHtml(__('Special Price')),
'price_id' => $block->escapeHtml($block->getPriceId('product-price-' . $idSuffix)),
'display_label' => $escaper->escapeHtml(__('Special Price')),
'price_id' => $escaper->escapeHtml($block->getPriceId('product-price-' . $idSuffix)),
'price_type' => 'finalPrice',
'include_container' => true,
'schema' => $schema,
Expand All @@ -27,8 +31,8 @@ $idSuffix = $block->getIdSuffix() ?: '';
<?= /* @noEscape */ $block->renderAmount(
$block->getConfiguredRegularPrice()->getAmount(),
[
'display_label' => $block->escapeHtml(__('Regular Price')),
'price_id' => $block->escapeHtml($block->getPriceId('old-price-' . $idSuffix)),
'display_label' => $escaper->escapeHtml(__('Regular Price')),
'price_id' => $escaper->escapeHtml($block->getPriceId('old-price-' . $idSuffix)),
'price_type' => 'oldPrice',
'include_container' => true,
'skip_adjustments' => true,
Expand All @@ -46,8 +50,8 @@ $idSuffix = $block->getIdSuffix() ?: '';
<?= /* @noEscape */ $block->renderAmount(
$block->getConfiguredPrice()->getAmount(),
[
'display_label' => $block->escapeHtml($priceLabel),
'price_id' => $block->escapeHtml($block->getPriceId('product-price-' . $idSuffix)),
'display_label' => $escaper->escapeHtml($priceLabel),
'price_id' => $escaper->escapeHtml($block->getPriceId('product-price-' . $idSuffix)),
'price_type' => 'finalPrice',
'include_container' => true,
'schema' => $schema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php
/** @var \Magento\Wishlist\Pricing\Render\ConfiguredPriceBox $block */
declare(strict_types=1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line above copyright


use Magento\Framework\Escaper;
use Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct;
use Magento\Wishlist\Pricing\Render\ConfiguredPriceBox;

/** @var Escaper $escaper */
/** @var ConfiguredPriceBox $block */
$schema = ($block->getZone() == 'item_view');
$idSuffix = $block->getIdSuffix() ?: '';
/** @var \Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct $configuredPrice */

/** @var ConfigurableProduct $configuredPrice */
$configuredPrice = $block->getPrice();
$configuredRegularAmountValue = $configuredPrice->getConfiguredRegularAmount()->getValue();
?>
Expand All @@ -20,8 +26,8 @@ $configuredRegularAmountValue = $configuredPrice->getConfiguredRegularAmount()->
<?= /* @noEscape */ $block->renderAmount(
$configuredPrice->getConfiguredAmount(),
[
'display_label' => $block->escapeHtml(__('Special Price')),
'price_id' => $block->escapeHtml($block->getPriceId('product-price-' . $idSuffix)),
'display_label' => $escaper->escapeHtml(__('Special Price')),
'price_id' => $escaper->escapeHtml($block->getPriceId('product-price-' . $idSuffix)),
'price_type' => 'finalPrice',
'include_container' => true,
'schema' => $schema,
Expand All @@ -32,8 +38,8 @@ $configuredRegularAmountValue = $configuredPrice->getConfiguredRegularAmount()->
<?= /* @noEscape */ $block->renderAmount(
$configuredPrice->getConfiguredRegularAmount(),
[
'display_label' => $block->escapeHtml(__('Regular Price')),
'price_id' => $block->escapeHtml($block->getPriceId('old-price-' . $idSuffix)),
'display_label' => $escaper->escapeHtml(__('Regular Price')),
'price_id' => $escaper->escapeHtml($block->getPriceId('old-price-' . $idSuffix)),
'price_type' => 'oldPrice',
'include_container' => true,
'skip_adjustments' => true,
Expand All @@ -51,8 +57,8 @@ $configuredRegularAmountValue = $configuredPrice->getConfiguredRegularAmount()->
<?= /* @noEscape */ $block->renderAmount(
$configuredPrice->getAmount(),
[
'display_label' => $block->escapeHtml($priceLabel),
'price_id' => $block->escapeHtml($block->getPriceId('product-price-' . $idSuffix)),
'display_label' => $escaper->escapeHtml($priceLabel),
'price_id' => $escaper->escapeHtml($block->getPriceId('product-price-' . $idSuffix)),
'price_type' => 'finalPrice',
'include_container' => true,
'schema' => $schema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line above copyright


/** @var \Magento\Wishlist\Block\Customer\Wishlist\Button $block */
use Magento\Framework\Escaper;
use Magento\Wishlist\Block\Customer\Wishlist\Button;

/** @var Escaper $escaper */
/** @var Button $block */
?>
<?php if ($block->getWishlist()->getItemsCount() && $block->getWishlist()->getShared() < $block->getConfig()->getSharingEmailLimit()) : ?>
<button type="submit" name="save_and_share" title="<?= $block->escapeHtmlAttr(__('Share Wish List')) ?>" class="action share">
<span><?= $block->escapeHtml(__('Share Wish List')) ?></span>
<button type="submit"
name="save_and_share"
title="<?= $escaper->escapeHtmlAttr(__('Share Wish List')) ?>"
class="action share">
<span><?= $escaper->escapeHtml(__('Share Wish List')) ?></span>
</button>
<?php endif;?>
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line above copyright


/** @var \Magento\Wishlist\Block\Customer\Wishlist\Button $block */
use Magento\Framework\Escaper;
use Magento\Wishlist\Block\Customer\Wishlist\Button;

/** @var Escaper $escaper */
/** @var Button $block */
?>

<?php if ($block->getWishlist()->getItemsCount() && $block->getWishlist()->isSalable()) : ?>
<button type="button" data-role="all-tocart" title="<?= $block->escapeHtmlAttr(__('Add All to Cart')) ?>" class="action tocart">
<span><?= $block->escapeHtml(__('Add All to Cart')) ?></span>
<button type="button"
data-role="all-tocart"
title="<?= $escaper->escapeHtmlAttr(__('Add All to Cart')) ?>"
class="action tocart">
<span><?= $escaper->escapeHtml(__('Add All to Cart')) ?></span>
</button>
<?php endif;?>
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line above copyright


/** @var \Magento\Wishlist\Block\Customer\Wishlist\Button $block */
?>
use Magento\Framework\Escaper;
use Magento\Wishlist\Block\Customer\Wishlist\Button;

/** @var Escaper $escaper */
/** @var Button $block */
?>
<?php if ($block->getWishlist()->getItemsCount()) : ?>
<button type="submit" name="do" title="<?= $block->escapeHtmlAttr(__('Update Wish List')) ?>" class="action update">
<span><?= $block->escapeHtml(__('Update Wish List')) ?></span>
<button type="submit"
name="do"
title="<?= $escaper->escapeHtmlAttr(__('Update Wish List')) ?>"
class="action update">
<span><?= $escaper->escapeHtml(__('Update Wish List')) ?></span>
</button>
<?php endif;?>
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line above copyright


/** @var \Magento\Wishlist\Block\Cart\Item\Renderer\Actions\MoveToWishlist $block */
use Magento\Framework\Escaper;
use Magento\Wishlist\Block\Cart\Item\Renderer\Actions\MoveToWishlist;

/** @var Escaper $escaper */
/** @var MoveToWishlist $block */
?>
<?php if ($block->isAllowInCart() && $block->isProductVisibleInSiteVisibility()) : ?>
<a href="#"
data-post='<?= /* @noEscape */ $block->getMoveFromCartParams() ?>'
class="use-ajax action towishlist action-towishlist">
<span><?= $block->escapeHtml(__('Move to Wishlist')) ?></span>
<span><?= $escaper->escapeHtml(__('Move to Wishlist')) ?></span>
</a>
<?php endif ?>
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

/** @var Magento\Wishlist\Block\Catalog\Product\ProductList\Item\AddTo\Wishlist $block */
use Magento\Framework\Escaper;
use Magento\Wishlist\Block\Catalog\Product\ProductList\Item\AddTo\Wishlist;

/** @var Escaper $escaper */
/** @var Wishlist $block */
?>
<?php if ($block->getWishlistHelper()->isAllow()) : ?>
<a href="#"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line above copyright


/** @var \Magento\Wishlist\Block\Catalog\Product\View\AddTo\Wishlist $block */
use Magento\Framework\Escaper;
use Magento\Wishlist\Block\Catalog\Product\View\AddTo\Wishlist;

/** @var Escaper $escaper */
/** @var Wishlist $block */
?>
<?php if ($block->isWishListAllowed()) : ?>
<a href="#"
class="action towishlist"
data-post='<?= /* @noEscape */ $block->getWishlistParams() ?>'
data-action="add-to-wishlist"><span><?= $block->escapeHtml(__('Add to Wish List')) ?></span></a>
data-action="add-to-wishlist"><span><?= $escaper->escapeHtml(__('Add to Wish List')) ?></span></a>
<?php endif; ?>
<script type="text/x-magento-init">
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line above copyright


/* @var \Magento\Wishlist\Block\Share\Email\Items $block */
use Magento\Framework\Escaper;
use Magento\Wishlist\Block\Share\Email\Items;

/** @var Escaper $escaper */
/* @var Items $block */
?>
<?php $l = $block->getWishlistItemsCount() ?>
<div>
Expand All @@ -17,26 +22,26 @@
<?php $_product = $item->getProduct(); ?>
<td class="col product">
<p>
<a href="<?= $block->escapeUrl($block->getProductUrl($item)) ?>">
<a href="<?= $escaper->escapeUrl($block->getProductUrl($item)) ?>">
<?php $productThumbnail = $block->getProductForThumbnail($item) ?>
<?= /* @noEscape */ $block->getImage($productThumbnail, 'product_small_image')->toHtml() ?>
</a>
</p>

<p>
<a href="<?= $block->escapeUrl($block->getProductUrl($item)) ?>">
<strong><?= $block->escapeHtml($_product->getName()) ?></strong>
<a href="<?= $escaper->escapeUrl($block->getProductUrl($item)) ?>">
<strong><?= $escaper->escapeHtml($_product->getName()) ?></strong>
</a>
</p>
<?php if ($block->hasDescription($item)): ?>
<p>
<strong><?= $block->escapeHtml(__('Comment')) ?>:</strong>
<strong><?= $escaper->escapeHtml(__('Comment')) ?>:</strong>
<br/><?= /* @noEscape */ $block->getEscapedDescription($item) ?>
</p>
<?php endif; ?>
<p>
<a href="<?= $block->escapeUrl($block->getProductUrl($item)) ?>">
<?= $block->escapeHtml(__('View Product')) ?>
<a href="<?= $escaper->escapeUrl($block->getProductUrl($item)) ?>">
<?= $escaper->escapeHtml(__('View Product')) ?>
</a>
</p>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line above copyright


/** @var \Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Actions $block */
use Magento\Framework\Escaper;
use Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Actions;

/** @var Escaper $escaper */
/** @var Actions $block */
?>
<?php $children = $block->getChildNames(); ?>
<?php if ($children) : ?>
<div class="<?= $block->escapeHtmlAttr($block->getCssClass()) ?>">
<div class="<?= $escaper->escapeHtmlAttr($block->getCssClass()) ?>">
<?php foreach ($children as $childName) : ?>
<?= /* @noEscape */ $block->getLayout()->renderElement($childName, false) ?>
<?php endforeach;?>
Expand Down
Loading