Skip to content

Magento_Bundle: avoid using deprecated escape* methods from AbstractB… #31686

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
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function getOrderItem()
*/
public function getValueHtml($item)
{
$result = $this->escapeHtml($item->getName());
$result = $this->_escaper->escapeHtml($item->getName());
if (!$this->isShipmentSeparately($item)) {
$attributes = $this->getSelectionAttributes($item);
if ($attributes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function getOrderOptions()
*/
public function getValueHtml($item)
{
$result = $this->escapeHtml($item->getName());
$result = $this->_escaper->escapeHtml($item->getName());
if (!$this->isShipmentSeparately($item)) {
$attributes = $this->getSelectionAttributes($item);
if ($attributes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function getSelectionQtyTitlePrice($selection, $includeContainer = true)
$priceTitle = '<span class="product-name">'
. $selection->getSelectionQty() * 1
. ' x '
. $this->escapeHtml($selection->getName())
. $this->_escaper->escapeHtml($selection->getName())
. '</span>';

$priceTitle .= ' &nbsp; ' . ($includeContainer ? '<span class="price-notice">' : '') . '+' .
Expand Down Expand Up @@ -285,7 +285,7 @@ public function getSelectionPrice($selection)
*/
public function getSelectionTitlePrice($selection, $includeContainer = true)
{
$priceTitle = '<span class="product-name">' . $this->escapeHtml($selection->getName()) . '</span>';
$priceTitle = '<span class="product-name">' . $this->_escaper->escapeHtml($selection->getName()) . '</span>';
$priceTitle .= ' &nbsp; ' . ($includeContainer ? '<span class="price-notice">' : '') . '+'
. $this->renderPriceString($selection, $includeContainer) . ($includeContainer ? '</span>' : '');
return $priceTitle;
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ public function getSelectionAttributes($item)
public function getValueHtml($item)
{
if ($attributes = $this->getSelectionAttributes($item)) {
return sprintf('%d', $attributes['qty']) . ' x ' . $this->escapeHtml($item->getName()) . " "
return sprintf('%d', $attributes['qty']) . ' x ' . $this->_escaper->escapeHtml($item->getName()) . " "
. $this->getOrder()->formatPrice($attributes['price']);
}
return $this->escapeHtml($item->getName());
return $this->_escaper->escapeHtml($item->getName());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
* See COPYING.txt for license details.
*/

/** @var $block \Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Attributes\Extend */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
/**
* @var \Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Attributes\Extend $block
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
* @var \Magento\Framework\Escaper $escaper
*/
$elementHtml = $block->getParentElementHtml();

$attributeCode = $block->getAttribute()
Expand All @@ -20,7 +23,7 @@ $isElementReadonly = $block->getElement()
?>

<?php if (!($attributeCode === 'price' && $block->getCanReadPrice() === false)): ?>
<div class="<?= $block->escapeHtmlAttr($attributeCode) ?> "><?= /* @noEscape */ $elementHtml ?></div>
<div class="<?= $escaper->escapeHtmlAttr($attributeCode) ?> "><?= /* @noEscape */ $elementHtml ?></div>
<?php endif; ?>

<?= $block->getExtendedElement($switchAttributeCode)->toHtml() ?>
Expand All @@ -30,8 +33,8 @@ $isElementReadonly = $block->getElement()
$scriptString = <<<script
require(['prototype'], function () {
function {$switchAttributeCode}_change() {
var $attribute = $('{$block->escapeJs($attributeCode)}');
if ($('{$switchAttributeCode}').value == '{$block->escapeJs($block::DYNAMIC)}') {
var $attribute = $('{$escaper->escapeJs($attributeCode)}');
if ($('{$switchAttributeCode}').value == '{$escaper->escapeJs($block::DYNAMIC)}') {
if ($attribute) {
$attribute.disabled = true;
$attribute.value = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>

<?php
/* @var $block \Magento\Bundle\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Bundle */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
/**
* @var \Magento\Bundle\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Bundle $block
* @var \Magento\Framework\Escaper $escaper
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
*/
?>

<?php $options = $block->decorateArray($block->getOptions(true)); ?>
<?php if (count($options)): ?>
<fieldset id="catalog_product_composite_configure_fields_bundle"
class="fieldset admin__fieldset composite-bundle<?= $block->getIsLastFieldset() ? ' last-fieldset' : '' ?>">
<legend class="legend admin__legend">
<span><?= $block->escapeHtml(__('Bundle Items')) ?></span>
<span><?= $escaper->escapeHtml(__('Bundle Items')) ?></span>
</legend><br />
<?php foreach ($options as $option): ?>
<?php if ($option->getSelections()): ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis

/**
* @var \Magento\Bundle\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Options\Type\Checkbox $block
* @var \Magento\Framework\Escaper $escaper
*/
?>
<?php /* @var $block \Magento\Bundle\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Options\Type\Checkbox */ ?>
<?php $_option = $block->getOption(); ?>
<?php $_selections = $_option->getSelections(); ?>
<?php $_skipSaleableCheck = $this->helper(Magento\Catalog\Helper\Product::class)->getSkipSaleableCheck(); ?>

<div class="field admin__field options<?php if ($_option->getRequired()) { echo ' _required'; } ?>">
<label class="label admin__field-label">
<span><?= $block->escapeHtml($_option->getTitle()) ?></span>
<span><?= $escaper->escapeHtml($_option->getTitle()) ?></span>
</label>

<div class="control admin__field-control">
Expand All @@ -21,30 +26,30 @@
<?php if (count($_selections) == 1 && $_option->getRequired()) : ?>
<?= /* @noEscape */ $block->getSelectionQtyTitlePrice($_selections[0]) ?>
<input type="hidden"
name="bundle_option[<?= $block->escapeHtmlAttr($_option->getId()) ?>]"
value="<?= $block->escapeHtmlAttr($_selections[0]->getSelectionId()) ?>"
price="<?= $block->escapeHtmlAttr($block->getSelectionPrice($_selections[0])) ?>" />
name="bundle_option[<?= $escaper->escapeHtmlAttr($_option->getId()) ?>]"
value="<?= $escaper->escapeHtmlAttr($_selections[0]->getSelectionId()) ?>"
price="<?= $escaper->escapeHtmlAttr($block->getSelectionPrice($_selections[0])) ?>" />
<?php else :?>

<?php foreach ($_selections as $_selection) : ?>
<div class="field choice admin__field admin__field-option">
<input
class="change-container-classname admin__control-checkbox checkbox bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?> <?php if ($_option->getRequired()) { echo 'validate-one-required-by-name'; } ?>"
id="bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?>-<?= $block->escapeHtmlAttr($_selection->getSelectionId()) ?>"
class="change-container-classname admin__control-checkbox checkbox bundle-option-<?= $escaper->escapeHtmlAttr($_option->getId()) ?> <?php if ($_option->getRequired()) { echo 'validate-one-required-by-name'; } ?>"
id="bundle-option-<?= $escaper->escapeHtmlAttr($_option->getId()) ?>-<?= $escaper->escapeHtmlAttr($_selection->getSelectionId()) ?>"
type="checkbox"
name="bundle_option[<?= $block->escapeHtmlAttr($_option->getId()) ?>][<?= $block->escapeHtmlAttr($_selection->getId()) ?>]"
name="bundle_option[<?= $escaper->escapeHtmlAttr($_option->getId()) ?>][<?= $escaper->escapeHtmlAttr($_selection->getId()) ?>]"
<?php if ($block->isSelected($_selection)) :?>
<?= ' checked="checked"' ?>
<?php endif;?>
<?php if (!$_selection->isSaleable() && !$_skipSaleableCheck) :?>
<?= ' disabled="disabled"' ?>
<?php endif;?>
value="<?= $block->escapeHtmlAttr($_selection->getSelectionId()) ?>"
value="<?= $escaper->escapeHtmlAttr($_selection->getSelectionId()) ?>"
onclick="ProductConfigure.bundleControl.changeSelection(this)"
price="<?= $block->escapeHtmlAttr($block->getSelectionPrice($_selection)) ?>" />
price="<?= $escaper->escapeHtmlAttr($block->getSelectionPrice($_selection)) ?>" />

<label class="admin__field-label"
for="bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?>-<?= $block->escapeHtmlAttr($_selection->getSelectionId()) ?>">
for="bundle-option-<?= $escaper->escapeHtmlAttr($_option->getId()) ?>-<?= $escaper->escapeHtmlAttr($_selection->getSelectionId()) ?>">
<span><?= /* @noEscape */ $block->getSelectionQtyTitlePrice($_selection) ?></span>
</label>

Expand All @@ -54,7 +59,7 @@
</div>
<?php endforeach; ?>

<div id="bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?>-container"></div>
<div id="bundle-option-<?= $escaper->escapeHtmlAttr($_option->getId()) ?>-container"></div>
<?php endif; ?>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,38 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis

/**
* @var \Magento\Bundle\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Options\Type\Multi $block
* @var \Magento\Framework\Escaper $escaper
*/
?>
<?php /* @var $block \Magento\Bundle\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Options\Type\Multi */ ?>
<?php $_option = $block->getOption(); ?>
<?php $_selections = $_option->getSelections(); ?>
<?php $_skipSaleableCheck = $this->helper(Magento\Catalog\Helper\Product::class)->getSkipSaleableCheck(); ?>
<div class="field admin__field <?php if ($_option->getRequired()) { echo ' _required'; } ?><?php if ($_option->getDecoratedIsLast()) :?> last<?php endif; ?>">
<label class="label admin__field-label"><span><?= $block->escapeHtml($_option->getTitle()) ?></span></label>
<label class="label admin__field-label"><span><?= $escaper->escapeHtml($_option->getTitle()) ?></span></label>
<div class="control admin__field-control">
<?php if (count($_selections) == 1 && $_option->getRequired()) : ?>
<?= /* @noEscape */ $block->getSelectionQtyTitlePrice($_selections[0]) ?>
<input type="hidden" name="bundle_option[<?= $block->escapeHtmlAttr($_option->getId()) ?>]"
value="<?= $block->escapeHtmlAttr($_selections[0]->getSelectionId()) ?>"
price="<?= $block->escapeHtmlAttr($block->getSelectionPrice($_selections[0])) ?>" />
<input type="hidden" name="bundle_option[<?= $escaper->escapeHtmlAttr($_option->getId()) ?>]"
value="<?= $escaper->escapeHtmlAttr($_selections[0]->getSelectionId()) ?>"
price="<?= $escaper->escapeHtmlAttr($block->getSelectionPrice($_selections[0])) ?>" />
<?php else : ?>
<select multiple="multiple" size="5" id="bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?>"
name="bundle_option[<?= $block->escapeHtmlAttr($_option->getId()) ?>][]"
class="admin__control-multiselect bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?><?php if ($_option->getRequired()) { echo ' required-entry'; } ?> multiselect change-container-classname"
<select multiple="multiple" size="5" id="bundle-option-<?= $escaper->escapeHtmlAttr($_option->getId()) ?>"
name="bundle_option[<?= $escaper->escapeHtmlAttr($_option->getId()) ?>][]"
class="admin__control-multiselect bundle-option-<?= $escaper->escapeHtmlAttr($_option->getId()) ?><?php if ($_option->getRequired()) { echo ' required-entry'; } ?> multiselect change-container-classname"
onchange="ProductConfigure.bundleControl.changeSelection(this)">
<?php if (!$_option->getRequired()) : ?>
<option value=""><?= $block->escapeHtml(__('None')) ?></option>
<option value=""><?= $escaper->escapeHtml(__('None')) ?></option>
<?php endif; ?>
<?php foreach ($_selections as $_selection) : ?>
<option value="<?= $block->escapeHtmlAttr($_selection->getSelectionId()) ?>"
<option value="<?= $escaper->escapeHtmlAttr($_selection->getSelectionId()) ?>"
<?php if ($block->isSelected($_selection)) { echo ' selected="selected"'; } ?>
<?php if (!$_selection->isSaleable() && !$_skipSaleableCheck) { echo ' disabled="disabled"'; } ?>
price="<?= $block->escapeHtmlAttr($block->getSelectionPrice($_selection)) ?>">
price="<?= $escaper->escapeHtmlAttr($block->getSelectionPrice($_selection)) ?>">
<?= /* @noEscape */ $block->getSelectionQtyTitlePrice($_selection, false) ?></option>
<?php endforeach; ?>
</select>
Expand Down
Loading