Skip to content

Magento_Tax: avoid using deprecated escape* methods from AbstractBlock #31722

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
4 changes: 2 additions & 2 deletions app/code/Magento/Tax/Block/Checkout/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function getIncludeTaxLabel()
{
return __(
'Shipping Incl. Tax (%1)',
$this->escapeHtml($this->getQuote()->getShippingAddress()->getShippingDescription())
$this->_escaper->escapeHtml($this->getQuote()->getShippingAddress()->getShippingDescription())
);
}

Expand All @@ -109,7 +109,7 @@ public function getExcludeTaxLabel()
{
return __(
'Shipping Excl. Tax (%1)',
$this->escapeHtml($this->getQuote()->getShippingAddress()->getShippingDescription())
$this->_escaper->escapeHtml($this->getQuote()->getShippingAddress()->getShippingDescription())
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Tax/Block/Grid/Renderer/Codes.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public function render(\Magento\Framework\DataObject $row)
{
$ratesCodes = $row->getTaxRatesCodes();

return $ratesCodes && is_array($ratesCodes) ? $this->escapeHtml(implode(', ', $ratesCodes)) : '';
return $ratesCodes && is_array($ratesCodes) ? $this->_escaper->escapeHtml(implode(', ', $ratesCodes)) : '';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@
// phpcs:disable Magento2.Templates.ThisInTemplate
?>
<?php
/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block */
/**
* @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block
* @var \Magento\Framework\Escaper $escaper
*/

$_item = $block->getItem();
?>
<?php if ($block->displayBothPrices() || $block->displayPriceExclTax()) : ?>
<div class="price-excl-tax">
<?php if ($block->displayBothPrices()) : ?>
<span class="label"><?= $block->escapeHtml(__('Excl. Tax')) ?>:</span>
<span class="label"><?= $escaper->escapeHtml(__('Excl. Tax')) ?>:</span>
<?php endif; ?>
<?= /* @noEscape */ $block->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?>
</div>
<?php endif; ?>
<?php if ($block->displayBothPrices() || $block->displayPriceInclTax()) : ?>
<div class="price-incl-tax">
<?php if ($block->displayBothPrices()) : ?>
<span class="label"><?= $block->escapeHtml(__('Incl. Tax')) ?>:</span>
<span class="label"><?= $escaper->escapeHtml(__('Incl. Tax')) ?>:</span>
<?php endif; ?>
<?php $_incl = $this->helper(\Magento\Checkout\Helper\Data::class)->getSubtotalInclTax($_item); ?>
<?php $_baseIncl = $this->helper(\Magento\Checkout\Helper\Data::class)->getBaseSubtotalInclTax($_item); ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
// phpcs:disable Magento2.Templates.ThisInTemplate
?>
<?php
/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block */
/**
* @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block
* @var \Magento\Framework\Escaper $escaper
*/

$_item = $block->getItem();
?>

<?php if ($this->helper(\Magento\Tax\Helper\Data::class)->displaySalesBothPrices() || $this->helper(\Magento\Tax\Helper\Data::class)->displaySalesPriceExclTax()) : ?>
<div class="price-excl-tax">
<?php if ($this->helper(\Magento\Tax\Helper\Data::class)->displaySalesBothPrices()) : ?>
<span class="label"><?= $block->escapeHtml(__('Excl. Tax')) ?>:</span>
<span class="label"><?= $escaper->escapeHtml(__('Excl. Tax')) ?>:</span>
<?php endif; ?>

<?= /* @noEscape */ $block->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?>
Expand All @@ -24,7 +27,7 @@ $_item = $block->getItem();
<?php if ($this->helper(\Magento\Tax\Helper\Data::class)->displaySalesBothPrices() || $this->helper(\Magento\Tax\Helper\Data::class)->displaySalesPriceInclTax()) : ?>
<div class="price-incl-tax">
<?php if ($this->helper(\Magento\Tax\Helper\Data::class)->displaySalesBothPrices()) : ?>
<span class="label"><?= $block->escapeHtml(__('Incl. Tax')) ?>:</span>
<span class="label"><?= $escaper->escapeHtml(__('Incl. Tax')) ?>:</span>
<?php endif; ?>
<?php $_incl = $this->helper(\Magento\Checkout\Helper\Data::class)->getPriceInclTax($_item); ?>
<?php $_baseIncl = $this->helper(\Magento\Checkout\Helper\Data::class)->getBasePriceInclTax($_item); ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@
// phpcs:disable Magento2.Templates.ThisInTemplate
?>
<?php
/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block */
/**
* @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block
* @var \Magento\Framework\Escaper $escaper
*/

$_item = $block->getItem();
?>

<?php if ($block->displayPriceExclTax() || $block->displayBothPrices()) : ?>
<?php if ($block->displayBothPrices($block->getStore())) : ?>
<span class="label"><?= $block->escapeHtml(__('Excl. Tax')) ?>:</span>
<span class="label"><?= $escaper->escapeHtml(__('Excl. Tax')) ?>:</span>
<?php endif; ?>
<?= /* @noEscape */ $block->formatPrice($_item->getRowTotal()) ?>
<?php endif; ?>

<?php if ($block->displayPriceInclTax() || $block->displayBothPrices()) : ?>
<?php if ($block->displayBothPrices()) : ?>
<br /><span class="label"><?= $block->escapeHtml(__('Incl. Tax')) ?>:</span>
<br /><span class="label"><?= $escaper->escapeHtml(__('Incl. Tax')) ?>:</span>
<?php endif; ?>
<?php $_incl = $this->helper(\Magento\Checkout\Helper\Data::class)->getSubtotalInclTax($_item); ?>
<?= /* @noEscape */ $block->formatPrice($_incl) ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,26 @@
*/
?>
<?php
/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block */
/**
* @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block
* @var \Magento\Framework\Escaper $escaper
*/

$_item = $block->getItem();
?>

<?php if ($block->displayPriceExclTax() || $block->displayBothPrices()) : ?>
<?php $_rowTotalWithoutDiscount = $_item->getRowTotal() - $_item->getTotalDiscountAmount(); ?>
<?php if ($block->displayBothPrices()) : ?>
<span class="label"><?= $block->escapeHtml(__('Excl. Tax')) ?>:</span>
<span class="label"><?= $escaper->escapeHtml(__('Excl. Tax')) ?>:</span>
<?php endif; ?>
<?= /* @noEscape */ $block->formatPrice(max(0, $_rowTotalWithoutDiscount)) ?>
<?php endif; ?>


<?php if ($block->displayPriceInclTax() || $block->displayBothPrices()) : ?>
<?php if ($block->displayBothPrices($block->getStore())) : ?>
<br /><span class="label"><?= $block->escapeHtml(__('Incl. Tax')) ?>:</span>
<br /><span class="label"><?= $escaper->escapeHtml(__('Incl. Tax')) ?>:</span>
<?php endif; ?>
<?php $_incl = $block->getTotalAmount($_item); ?>
<?= /* @noEscape */ $block->formatPrice($_incl) ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@
// phpcs:disable Magento2.Templates.ThisInTemplate
?>
<?php
/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block */
/**
* @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block
* @var \Magento\Framework\Escaper $escaper
*/

$_item = $block->getItem();
?>

<?php if ($block->displayPriceExclTax() || $block->displayBothPrices()) : ?>
<?php if ($block->displayBothPrices()) : ?>
<span class="label"><?= $block->escapeHtml(__('Excl. Tax')) ?>:</span>
<span class="label"><?= $escaper->escapeHtml(__('Excl. Tax')) ?>:</span>
<?php endif; ?>
<?= /* @noEscape */ $block->formatPrice($_item->getCalculationPrice()) ?>
<?php endif; ?>


<?php if ($block->displayPriceInclTax() || $block->displayBothPrices()) : ?>
<?php if ($block->displayBothPrices()) : ?>
<br /><span class="label"><?= $block->escapeHtml(__('Incl. Tax')) ?>:</span>
<br /><span class="label"><?= $escaper->escapeHtml(__('Incl. Tax')) ?>:</span>
<?php endif; ?>
<?php $_incl = $this->helper(\Magento\Checkout\Helper\Data::class)->getPriceInclTax($_item); ?>
<?= /* @noEscape */ $block->formatPrice($_incl) ?>
Expand Down
12 changes: 8 additions & 4 deletions app/code/Magento/Tax/view/adminhtml/templates/rate/title.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,33 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

/**
* @var \Magento\Framework\Escaper $escaper
*/
?>
<fieldset id="tax-rate-titles-table" class="admin__fieldset">
<?php $_labels = $block->getTitles() ?>
<?php foreach ($block->getStores() as $_store) : ?>
<div class="admin__field">
<label class="admin__field-label">
<span><?= $block->escapeHtml($_store->getName()) ?></span>
<span><?= $escaper->escapeHtml($_store->getName()) ?></span>
</label>
<div class="admin__field-control">
<input
class="admin__control-text<?php if ($_store->getId() == 0) : ?> required-entry<?php endif; ?>"
type="text"
name="title[<?= (int) $_store->getId() ?>]"
value="<?= $block->escapeHtmlAttr($_labels[(int) $_store->getId()]) ?>" />
value="<?= $escaper->escapeHtmlAttr($_labels[(int) $_store->getId()]) ?>" />
</div>
</div>
<?php endforeach; ?>

<div class="messages">
<div class="message message-notice">
<div>
<strong><?= $block->escapeHtml(__('Note:')) ?></strong>
<?= $block->escapeHtml(__('Leave this field empty if you wish to use the tax identifier.')) ?>
<strong><?= $escaper->escapeHtml(__('Note:')) ?></strong>
<?= $escaper->escapeHtml(__('Leave this field empty if you wish to use the tax identifier.')) ?>
</div>
</div>
</div>
Expand Down
33 changes: 18 additions & 15 deletions app/code/Magento/Tax/view/adminhtml/templates/rule/edit.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
* See COPYING.txt for license details.
*/

/** @var $block \Magento\Tax\Block\Adminhtml\Rule\Edit\Form */
/**
* @var $block \Magento\Tax\Block\Adminhtml\Rule\Edit\Form
* @var \Magento\Framework\Escaper $escaper
*/
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>
<?php $formElementId = /* @noEscape */ \Magento\Tax\Block\Adminhtml\Rate\Form::FORM_ELEMENT_ID;
Expand Down Expand Up @@ -81,7 +84,7 @@ require([
$.ajax({
type: "POST",
data: {id:id},
url: '{$block->escapeJs($block->getTaxRateLoadUrl())}',
url: '{$escaper->escapeJs($block->getTaxRateLoadUrl())}',
success: function(result, status) {
$('body').trigger('processStop');
if (result.success) {
Expand All @@ -98,14 +101,14 @@ require([
});
else
alert({
content: '{$block->escapeJs(__('An error occurred'))}'
content: '{$escaper->escapeJs(__('An error occurred'))}'
});
}
},
error: function () {
$('body').trigger('processStop');
alert({
content: '{$block->escapeJs(__('An error occurred'))}'
content: '{$escaper->escapeJs(__('An error occurred'))}'
});
},
dataType: "json"
Expand All @@ -116,9 +119,9 @@ require([
var options = {
mselectContainer: '#tax_rate + section.mselect-list',
toggleAddButton:false,
addText: '{$block->escapeJs(__('Add New Tax Rate'))}',
addText: '{$escaper->escapeJs(__('Add New Tax Rate'))}',
parse: null,
nextPageUrl: '{$block->escapeJs($block->getTaxRatesPageUrl())}',
nextPageUrl: '{$escaper->escapeJs($block->getTaxRatesPageUrl())}',
selectedValues: this.settings.selected_values,
mselectInputSubmitCallback: function (value, options) {
var select = $('#tax_rate');
Expand Down Expand Up @@ -175,7 +178,7 @@ script;
rateValue = that.parent().find('input[type="checkbox"]').val();

confirm({
content: '{$block->escapeJs(__('Do you really want to delete this tax rate?'))}',
content: '{$escaper->escapeJs(__('Do you really want to delete this tax rate?'))}',
actions: {
/**
* Confirm action.
Expand All @@ -189,7 +192,7 @@ script;
form_key: $('input[name="form_key"]').val()
},
dataType: 'json',
url: '{$block->escapeJs($block->getTaxRateDeleteUrl())}',
url: '{$escaper->escapeJs($block->getTaxRateDeleteUrl())}',
success: function(result, status) {
$('body').trigger('processStop');
if (result.success) {
Expand All @@ -207,14 +210,14 @@ script;
});
else
alert({
content: '{$block->escapeJs(__('An error occurred'))}'
content: '{$escaper->escapeJs(__('An error occurred'))}'
});
}
},
error: function () {
$('body').trigger('processStop');
alert({
content: '{$block->escapeJs(__('An error occurred'))}'
content: '{$escaper->escapeJs(__('An error occurred'))}'
});
}
};
Expand All @@ -237,15 +240,15 @@ script;
taxRateFormElement.mage('form').mage('validation');

taxRateForm.dialogRates({
title: '{$block->escapeJs(__('Tax Rate'))}',
title: '{$escaper->escapeJs(__('Tax Rate'))}',
type: 'slide',
id: '{$jsId}',
modalClass: 'tax-rate-popup',
closed: function () {
taxRateFormElement.data('validation').clearError();
},
buttons: [{
text: '{$block->escapeJs(__('Save'))}',
text: '{$escaper->escapeJs(__('Save'))}',
'class': 'action-save action-primary',
click: function() {
this.updateItemRate();
Expand All @@ -270,7 +273,7 @@ $scriptString.= <<<script
type: 'POST',
data: itemRateData,
dataType: 'json',
url: '{$block->escapeJs($block->getTaxRateSaveUrl())}',
url: '{$escaper->escapeJs($block->getTaxRateSaveUrl())}',
success: function(result, status) {
$('body').trigger('processStop');
if (result.success) {
Expand All @@ -295,14 +298,14 @@ $scriptString.= <<<script
});
else
alert({
content: '{$block->escapeJs(__('An error occurred'))}'
content: '{$escaper->escapeJs(__('An error occurred'))}'
});
}
},
error: function () {
$('body').trigger('processStop');
alert({
content: '{$block->escapeJs(__('An error occurred'))}'
content: '{$escaper->escapeJs(__('An error occurred'))}'
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/* @var $block \Magento\Tax\Block\Adminhtml\Rate\Form */
/**
* @var $block \Magento\Tax\Block\Adminhtml\Rate\Form
* @var \Magento\Framework\Escaper $escaper
*/
?>

<div data-role="spinner" class="grid-loading-mask">
<div class="grid-loader"></div>
</div>

<div class="form-inline no-display" id="<?= $block->escapeHtmlAttr($block->getNameInLayout()) ?>">
<div class="form-inline no-display" id="<?= $escaper->escapeHtmlAttr($block->getNameInLayout()) ?>">
<?= $block->getFormHtml() ?>
<?= $block->getChildHtml('form_after') ?>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
* See COPYING.txt for license details.
*/
// @deprecated
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
/**
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
* @var \Magento\Framework\Escaper $escaper
*/
?>
<div data-mage-init='{"floatingHeader": {}}' class="page-actions">
<button type="button" id="addNewClass">
<?= $block->escapeHtml(__('Add New Class')) ?>
<?= $escaper->escapeHtml(__('Add New Class')) ?>
</button>
<?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag(
'onclick',
"window.location.href='" . $block->escapeJs($createUrl) . "'",
"window.location.href='" . $escaper->escapeJs($createUrl) . "'",
'button#addNewClass'
) ?>
</div>
Loading