Skip to content

Magento_Downloadable: avoid using deprecated escape* methods from Abs… #31669

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 @@ -252,7 +252,7 @@ public function getLinkData()
foreach ($links as $item) {
$tmpLinkItem = [
'link_id' => $item->getId(),
'title' => $this->escapeHtml($item->getTitle()),
'title' => $this->_escaper->escapeHtml($item->getTitle()),
'price' => $this->getCanReadPrice() ? $this->getPriceValue($item->getPrice()) : '',
'number_of_downloads' => $item->getNumberOfDownloads(),
'is_shareable' => $item->getIsShareable(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function getSampleData()
foreach ($samples as $item) {
$tmpSampleItem = [
'sample_id' => $item->getId(),
'title' => $this->escapeHtml($item->getTitle()),
'title' => $this->_escaper->escapeHtml($item->getTitle()),
'sample_url' => $item->getSampleUrl(),
'sample_type' => $item->getSampleType(),
'sort_order' => $item->getSortOrder(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,42 @@
*/
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
// @deprecated

/**
* @var $block \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Downloadable
* @var \Magento\Framework\Escaper $escaper
*/
?>
<?php /* @var $block \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Downloadable */ ?>
<?php $_linksPurchasedSeparately = $block->getLinksPurchasedSeparately(); ?>
<?php $_skipSaleableCheck = $this->helper(Magento\Catalog\Helper\Product::class)->getSkipSaleableCheck(); ?>
<?php if (($block->getProduct()->isSaleable() || $_skipSaleableCheck) && $block->hasLinks()) :?>

<fieldset id="catalog_product_composite_configure_fields_downloadable"
class="fieldset admin__fieldset downloadable information<?= $block->getIsLastFieldset() ? ' last-fieldset' : '' ?>">
<legend class="legend admin__legend">
<span><?= $block->escapeHtml(__('Downloadable Information')) ?></span>
<span><?= $escaper->escapeHtml(__('Downloadable Information')) ?></span>
</legend><br />
<?php $_links = $block->getLinks(); ?>
<?php $_isRequired = $block->getLinkSelectionRequired(); ?>
<div class="field admin__field link<?php if ($_isRequired) { echo ' _required'; } ?>">
<label class="label admin__field-label"><span><?= $block->escapeHtml($block->getLinksTitle()) ?></span></label>
<label class="label admin__field-label"><span><?= $escaper->escapeHtml($block->getLinksTitle()) ?></span></label>
<div class="control admin__field-control" id="downloadable-links-list">
<?php foreach ($_links as $_link) : ?>
<div class="nested admin__field-option">
<?php if ($_linksPurchasedSeparately) : ?>
<input type="checkbox"
class="admin__control-checkbox checkbox<?php if ($_isRequired) :?> required-entry<?php endif; ?> product downloadable link"
name="links[]" id="links_<?= $block->escapeHtmlAttr($_link->getId()) ?>"
value="<?= $block->escapeHtmlAttr($_link->getId()) ?>"
<?= $block->escapeHtml($block->getLinkCheckedValue($_link)) ?>
price="<?= $block->escapeHtmlAttr($block->getCurrencyPrice($_link->getPrice())) ?>"/>
name="links[]" id="links_<?= $escaper->escapeHtmlAttr($_link->getId()) ?>"
value="<?= $escaper->escapeHtmlAttr($_link->getId()) ?>"
<?= $escaper->escapeHtml($block->getLinkCheckedValue($_link)) ?>
price="<?= $escaper->escapeHtmlAttr($block->getCurrencyPrice($_link->getPrice())) ?>"/>
<?php endif; ?>
<label for="links_<?= $block->escapeHtmlAttr($_link->getId()) ?>" class="label admin__field-label">
<?= $block->escapeHtml($_link->getTitle()) ?>
<label for="links_<?= $escaper->escapeHtmlAttr($_link->getId()) ?>" class="label admin__field-label">
<?= $escaper->escapeHtml($_link->getTitle()) ?>
<?php if ($_link->getSampleFile() || $_link->getSampleUrl()) : ?>
&nbsp;(<a href="<?= $block->escapeUrl($block->getLinkSampleUrl($_link)) ?>"
&nbsp;(<a href="<?= $escaper->escapeUrl($block->getLinkSampleUrl($_link)) ?>"
<?= /* @noEscape */ $block->getIsOpenInNewWindow() ? 'onclick="this.target=\'_blank\'"' : '' ?>>
<?= $block->escapeHtml(__('sample')) ?>
<?= $escaper->escapeHtml(__('sample')) ?>
</a>)
<?php endif; ?>
<?php if ($_linksPurchasedSeparately) : ?>
Expand All @@ -50,8 +54,8 @@
require(['prototype'], function(){

//<![CDATA[
$('links_<?= $block->escapeJs($_link->getId()) ?>').advaiceContainer = 'links-advice-container';
$('links_<?= $block->escapeJs($_link->getId()) ?>').callbackFunction = 'validateDownloadableCallback';
$('links_<?= $escaper->escapeJs($_link->getId()) ?>').advaiceContainer = 'links-advice-container';
$('links_<?= $escaper->escapeJs($_link->getId()) ?>').callbackFunction = 'validateDownloadableCallback';
//]]>

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
*/

// @deprecated
?>

<?php
/**
* @var $block \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable
* @var \Magento\Framework\Escaper $escaper
*/
?>
<script>
Expand All @@ -28,7 +27,7 @@ var uploaderTemplate = '<div class="no-display" id="[[idName]]-template">' +
'<div class="no-display" id="[[idName]]-template-progress">' +
'<%- data.percent %>% <%- data.uploaded %> / <%- data.total %>' +
'</div>',

fileListTemplate = '<span class="file-info">' +
'<span class="file-info-name"><%= data.name %></span>' +
' ' +
Expand Down Expand Up @@ -202,15 +201,15 @@ var uploaderTemplate = '<div class="no-display" id="[[idName]]-template">' +
});
</script>

<div data-tab-type="tab_content_downloadableInfo" id="<?= $block->escapeHtmlAttr($block->getId()) ?>_content"
<?= $block->escapeHtml($block->getUiId('tab', 'content', $block->getId())) ?>
<div data-tab-type="tab_content_downloadableInfo" id="<?= $escaper->escapeHtmlAttr($block->getId()) ?>_content"
<?= $escaper->escapeHtml($block->getUiId('tab', 'content', $block->getId())) ?>
>
<div id="alert_messages_block"><?= $block->getMessageHtml() ?></div>
<div class="admin__field admin__field-option admin__field-is-downloaodable">
<input type="checkbox" data-action="change-type-product-downloadable" class="admin__control-checkbox"
name="is_downloadable" id="is-downloaodable" <?= $block->isDownloadable() ? 'checked="checked"' : ''?> />
<label class="admin__field-label" for="is-downloaodable">
<span><?= $block->escapeHtml(__('Is this a downloadable Product?')); ?></span>
<span><?= $escaper->escapeHtml(__('Is this a downloadable Product?')); ?></span>
</label>
</div>
<div class="entry-edit" id="product_info_tabs_downloadable_items">
Expand Down
Loading