Skip to content

Magento_Wishlist: Avoid using deprecated escape* methods from AbstractBlock #31662

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 1 commit 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
2 changes: 1 addition & 1 deletion app/code/Magento/Wishlist/Block/AbstractBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function getItemConfigureUrl($product)
public function getEscapedDescription($item)
{
if ($item->getDescription()) {
return $this->escapeHtml($item->getDescription());
return $this->_escaper->escapeHtml($item->getDescription());
}
return ' ';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getWishlistOptionsJson()
*/
public function getWishlistOptions()
{
return ['productType' => $this->escapeHtml($this->getProduct()->getTypeId())];
return ['productType' => $this->_escaper->escapeHtml($this->getProduct()->getTypeId())];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Wishlist/Block/Customer/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function getEnteredData($key)
if (!$this->_enteredData || !isset($this->_enteredData[$key])) {
return null;
} else {
return $this->escapeHtml($this->_enteredData[$key]);
return $this->_escaper->escapeHtml($this->_enteredData[$key]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ public function getConfiguredOptions()
if (!(array_key_exists('has_html', $option) && $option['has_html'] === true)) {
if (is_array($option['value'])) {
foreach ($option['value'] as $key => $value) {
$option['value'][$key] = $this->escapeHtml($value);
$option['value'][$key] = $this->_escaper->escapeHtml($value);
}
} else {
$option['value'] = $this->escapeHtml($option['value'], ["a"]);
$option['value'] = $this->_escaper->escapeHtml($option['value'], ["a"]);
}
}
$options[$index]['value'] = $option['value'];
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Wishlist/Block/Item/Configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(
*/
public function getWishlistOptions()
{
return ['productType' => $this->escapeHtml($this->getProduct()->getTypeId())];
return ['productType' => $this->_escaper->escapeHtml($this->getProduct()->getTypeId())];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Wishlist/Block/Share/Wishlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ public function getWishlistCustomer()
*/
public function getHeader()
{
return __("%1's Wish List", $this->escapeHtml($this->getWishlistCustomer()->getFirstname()));
return __("%1's Wish List", $this->_escaper->escapeHtml($this->getWishlistCustomer()->getFirstname()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
* See COPYING.txt for license details.
*/

/** @var \Magento\Framework\View\Element\Template $block */
/**
* @var \Magento\Framework\View\Element\Template $block
* @var \Magento\Framework\Escaper $escaper
*/
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>
<?php $scriptString = <<<script
Expand All @@ -21,14 +24,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 +54,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 +67,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 @@ -5,7 +5,10 @@
*/
?>
<?php
/** @var \Magento\Catalog\Pricing\Render\ConfiguredPriceBox $block */
/**
* @var \Magento\Catalog\Pricing\Render\ConfiguredPriceBox $block
* @var \Magento\Framework\Escaper $escaper
*/
$schema = ($block->getZone() == 'item_view');
$idSuffix = $block->getIdSuffix() ?: '';
?>
Expand All @@ -15,8 +18,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 +30,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 +49,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 @@ -5,7 +5,10 @@
*/
?>
<?php
/** @var \Magento\Wishlist\Pricing\Render\ConfiguredPriceBox $block */
/**
* @var \Magento\Wishlist\Pricing\Render\ConfiguredPriceBox $block
* @var \Magento\Framework\Escaper $escaper
*/
$schema = ($block->getZone() == 'item_view');
$idSuffix = $block->getIdSuffix() ?: '';
/** @var \Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct $configuredPrice */
Expand All @@ -20,8 +23,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 +35,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 +54,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 @@ -4,10 +4,13 @@
* See COPYING.txt for license details.
*/

/** @var \Magento\Wishlist\Block\Customer\Wishlist\Button $block */
/**
* @var \Magento\Wishlist\Block\Customer\Wishlist\Button $block
* @var \Magento\Framework\Escaper $escaper
*/
?>
<?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 @@ -4,11 +4,14 @@
* See COPYING.txt for license details.
*/

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

<?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 @@ -4,11 +4,14 @@
* See COPYING.txt for license details.
*/

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

<?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 @@ -4,12 +4,15 @@
* See COPYING.txt for license details.
*/

/** @var \Magento\Wishlist\Block\Cart\Item\Renderer\Actions\MoveToWishlist $block */
/**
* @var \Magento\Wishlist\Block\Cart\Item\Renderer\Actions\MoveToWishlist $block
* @var \Magento\Framework\Escaper $escaper
*/
?>
<?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 @@ -4,16 +4,19 @@
* See COPYING.txt for license details.
*/

/** @var Magento\Wishlist\Block\Catalog\Product\ProductList\Item\AddTo\Wishlist $block */
/**
* @var Magento\Wishlist\Block\Catalog\Product\ProductList\Item\AddTo\Wishlist $block
* @var \Magento\Framework\Escaper $escaper
*/
?>
<?php if ($block->getWishlistHelper()->isAllow()) : ?>
<a href="#"
class="action towishlist"
title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>"
aria-label="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>"
title="<?= $escaper->escapeHtmlAttr(__('Add to Wish List')) ?>"
aria-label="<?= $escaper->escapeHtmlAttr(__('Add to Wish List')) ?>"
data-post='<?= /* @noEscape */ $block->getAddToWishlistParams($block->getProduct()) ?>'
data-action="add-to-wishlist"
role="button">
<span><?= $block->escapeHtml(__('Add to Wish List')) ?></span>
<span><?= $escaper->escapeHtml(__('Add to Wish List')) ?></span>
</a>
<?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
* See COPYING.txt for license details.
*/

/** @var \Magento\Wishlist\Block\Catalog\Product\View\AddTo\Wishlist $block */
/**
* @var \Magento\Wishlist\Block\Catalog\Product\View\AddTo\Wishlist $block
* @var \Magento\Framework\Escaper $escaper
*/
?>
<?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 @@ -4,7 +4,10 @@
* See COPYING.txt for license details.
*/

/* @var \Magento\Wishlist\Block\Share\Email\Items $block */
/**
* @var \Magento\Framework\Escaper $escaper
* @var \Magento\Wishlist\Block\Share\Email\Items $block
*/
?>
<?php $l = $block->getWishlistItemsCount() ?>
<div>
Expand All @@ -17,26 +20,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 @@ -4,11 +4,14 @@
* See COPYING.txt for license details.
*/

/** @var \Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Actions $block */
/**
* @var \Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Actions $block
* @var \Magento\Framework\Escaper $escaper
*/
?>
<?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