Skip to content

Magento_Review: avoid using deprecated escape* methods from AbstractB… #31688

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
2 changes: 1 addition & 1 deletion app/code/Magento/Review/Block/Adminhtml/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public function getHeaderText()
{
$reviewData = $this->_coreRegistry->registry('review_data');
if ($reviewData && $reviewData->getId()) {
return __("Edit Review '%1'", $this->escapeHtml($reviewData->getTitle()));
return __("Edit Review '%1'", $this->_escaper->escapeHtml($reviewData->getTitle()));
} else {
return __('New Review');
}
Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/Review/Block/Adminhtml/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected function _prepareForm()
'text' => '<a href="' . $this->getUrl(
'catalog/product/edit',
['id' => $product->getId()]
) . '" onclick="this.target=\'blank\'">' . $this->escapeHtml(
) . '" onclick="this.target=\'blank\'">' . $this->_escaper->escapeHtml(
$product->getName()
) . '</a>'
]
Expand All @@ -124,9 +124,9 @@ protected function _prepareForm()
$customerText = __(
'<a href="%1" onclick="this.target=\'blank\'">%2 %3</a> <a href="mailto:%4">(%4)</a>',
$this->getUrl('customer/index/edit', ['id' => $customer->getId(), 'active_tab' => 'review']),
$this->escapeHtml($customer->getFirstname()),
$this->escapeHtml($customer->getLastname()),
$this->escapeHtml($customer->getEmail())
$this->_escaper->escapeHtml($customer->getFirstname()),
$this->_escaper->escapeHtml($customer->getLastname()),
$this->_escaper->escapeHtml($customer->getEmail())
);
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
$customerText = ($review->getStoreId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID)
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Review/Block/Adminhtml/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ protected function _construct()
$customerName = '';
if ($customerId) {
$customer = $this->customerRepository->getById($customerId);
$customerName = $this->escapeHtml($this->_customerViewHelper->getCustomerName($customer));
$customerName = $this->_escaper->escapeHtml($this->_customerViewHelper->getCustomerName($customer));
}
$productId = $this->getRequest()->getParam('productId', false);
$productName = null;
if ($productId) {
$product = $this->_productFactory->create()->load($productId);
$productName = $this->escapeHtml($product->getName());
$productName = $this->_escaper->escapeHtml($product->getName());
}

if ($this->_coreRegistry->registry('usePendingFilter') === true) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Review/Block/Adminhtml/Rating/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getHeaderText()
{
$ratingData = $this->_coreRegistry->registry('rating_data');
if ($ratingData && $ratingData->getId()) {
return __("Edit Rating #%1", $this->escapeHtml($ratingData->getRatingCode()));
return __("Edit Rating #%1", $this->_escaper->escapeHtml($ratingData->getRatingCode()));
} else {
return __('New Rating');
}
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Review/view/adminhtml/templates/add.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* See COPYING.txt for license details.
*/

/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
/**
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
*/
?>
<div data-mage-init='{"floatingHeader": {}}' class="page-actions">
<?= $block->getBackButtonHtml() ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@

/**
* @var \Magento\Review\Block\Adminhtml\Rating\Detailed $block
* @var \Magento\Framework\Escaper $escaper
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
*/

?>
<?php if ($block->getRating() && $block->getRating()->getSize()): ?>
<?php foreach ($block->getRating() as $_rating): ?>
<div class="admin__field admin__field-rating">
<label class="admin__field-label"><span><?= $block->escapeHtml($_rating->getRatingCode()) ?></span></label>
<label class="admin__field-label"><span><?= $escaper->escapeHtml($_rating->getRatingCode()) ?></span></label>
<?php $_iterator = 1; ?>
<?php $_options = ($_rating->getRatingOptions()) ? $_rating->getRatingOptions() : $_rating->getOptions() ?>
<div class="admin__field-control" data-widget="ratingControl">
<?php foreach (array_reverse($_options) as $_option): ?>
<input type="radio"
name="ratings[<?= $block->escapeHtmlAttr($_rating->getVoteId() ? $_rating->getVoteId() :
name="ratings[<?= $escaper->escapeHtmlAttr($_rating->getVoteId() ? $_rating->getVoteId() :
$_rating->getId()) ?>]"
id="<?= $block->escapeHtmlAttr($_rating->getRatingCode())
?>_<?= $block->escapeHtmlAttr($_option->getValue()) ?>"
value="<?= $block->escapeHtmlAttr($_option->getId()) ?>"
id="<?= $escaper->escapeHtmlAttr($_rating->getRatingCode())
?>_<?= $escaper->escapeHtmlAttr($_option->getValue()) ?>"
value="<?= $escaper->escapeHtmlAttr($_option->getId()) ?>"
<?php if ($block->isSelected($_option, $_rating)): ?>checked="checked"<?php endif; ?> />
<label for="<?= $block->escapeHtmlAttr($_rating->getRatingCode())
?>_<?= $block->escapeHtmlAttr($_option->getValue()) ?>">&#9733;</label>
<label for="<?= $escaper->escapeHtmlAttr($_rating->getRatingCode())
?>_<?= $escaper->escapeHtmlAttr($_option->getValue()) ?>">&#9733;</label>
<?php $_iterator++ ?>
<?php endforeach; ?>
</div>
Expand All @@ -49,5 +49,5 @@ script;
?>
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>
<?php else: ?>
<?= $block->escapeHtml(__("Rating isn't Available")) ?>
<?= $escaper->escapeHtml(__("Rating isn't Available")) ?>
<?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\Review\Block\Adminhtml\Rating\Edit\Tab\Form $block */
/**
* @var \Magento\Review\Block\Adminhtml\Rating\Edit\Tab\Form $block
* @var \Magento\Framework\Escaper $escaper
*/
?>
<div class="messages">
<div class="message message-notice message-in-rating-edit">
<div><?= $block->escapeHtml(__('Please specify a rating title for a store, or we\'ll just use the default value.')) ?></div>
<div><?= $escaper->escapeHtml(__('Please specify a rating title for a store, or we\'ll just use the default value.')) ?></div>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,27 @@
*/

// @deprecated

/**
* @var \Magento\Framework\Escaper $escaper
*/
?>
<div class="entry-edit-head">
<h4 class="icon-head head-edit-form fieldset-legend"><?= $block->escapeHtml(__('Assigned Options')) ?></h4>
<h4 class="icon-head head-edit-form fieldset-legend"><?= $escaper->escapeHtml(__('Assigned Options')) ?></h4>
</div>
<fieldset id="options_form">
<?php if (!$options) : ?>
<?php for ($_i = 1; $_i <= 5; $_i++) : ?>
<span class="field-row">
<label for="option_<?= /* @noEscape */ $_i ?>"><?= $block->escapeHtml(__('Option Title:')) ?></label>
<label for="option_<?= /* @noEscape */ $_i ?>"><?= $escaper->escapeHtml(__('Option Title:')) ?></label>
<input id="option_<?= /* @noEscape */ $_i ?>" name="option[<?= /* @noEscape */ $_i ?>][code]" value="<?= /* @noEscape */ $_i ?>" class="input-text" type="text" />
</span>
<?php endfor; ?>
<?php elseif ($options->getSize() > 0) : ?>
<?php foreach ($options->getItems() as $_item) : ?>
<span class="field-row">
<label for="option_<?= $block->escapeHtmlAttr($_item->getId()) ?>"><?= $block->escapeHtml(__('Option Title:')) ?></label>
<input id="option_<?= $block->escapeHtmlAttr($_item->getId()) ?>" name="option[<?= $block->escapeHtmlAttr($_item->getId()) ?>][code]" value="<?= $block->escapeHtmlAttr($_item->getCode()) ?>" class="input-text" type="text" />
<label for="option_<?= $escaper->escapeHtmlAttr($_item->getId()) ?>"><?= $escaper->escapeHtml(__('Option Title:')) ?></label>
<input id="option_<?= $escaper->escapeHtmlAttr($_item->getId()) ?>" name="option[<?= $escaper->escapeHtmlAttr($_item->getId()) ?>][code]" value="<?= $escaper->escapeHtmlAttr($_item->getCode()) ?>" class="input-text" type="text" />
</span>
<?php endforeach; ?>
<?php endif; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
*/

// @deprecated

/**
* @var \Magento\Framework\Escaper $escaper
*/
?>
<?php if ($block->getRating() && $block->getRating()->getSize()) : ?>
<div class="ratings-container">
<?php foreach ($block->getRating() as $_rating) : ?>
<?php if ($_rating->getPercent()) : ?>
<div class="ratings">
<?= $block->escapeHtml($_rating->getRatingCode()) ?>
<?= $escaper->escapeHtml($_rating->getRatingCode()) ?>
<div class="rating-box">
<div class="rating" style="width:<?= /* @noEscape */ ceil($_rating->getPercent()) ?>%;"></div>
</div>
Expand All @@ -20,5 +24,5 @@
<?php endforeach; ?>
</div>
<?php else : ?>
<?= $block->escapeHtml(__("Rating isn't Available")) ?>
<?= $escaper->escapeHtml(__("Rating isn't Available")) ?>
<?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/**
* @var \Magento\Review\Block\Adminhtml\Rating\Summary $block
* @var \Magento\Framework\Escaper $escaper
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
*/
?>
Expand All @@ -19,5 +20,5 @@
'div.rating-box div.rating'
) ?>
<?php else: ?>
<?= $block->escapeHtml(__("Rating isn't Available")) ?>
<?= $escaper->escapeHtml(__("Rating isn't Available")) ?>
<?php endif; ?>
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\Review\Block\Adminhtml\Grid\Rss\Link */
/**
* @var \Magento\Review\Block\Adminhtml\Grid\Rss\Link $block
* @var \Magento\Framework\Escaper $escaper
*/
?>
<?php if ($block->isRssAllowed() && $block->getLink()) : ?>
<a href="<?= $block->escapeUrl($block->getLink()) ?>" class="link-feed"><?= $block->escapeHtml($block->getLabel()) ?></a>
<a href="<?= $escaper->escapeUrl($block->getLink()) ?>" class="link-feed"><?= $escaper->escapeHtml($block->getLabel()) ?></a>
<?php endif; ?>
42 changes: 21 additions & 21 deletions app/code/Magento/Review/view/frontend/templates/customer/list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@

/**
* @var \Magento\Review\Block\Customer\ListCustomer $block
* @var \Magento\Framework\Escaper $escaper
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
* @var \Magento\Review\Helper\Data $reviewHelper
*/

/** @var \Magento\Review\Helper\Data $reviewHelper */
$reviewHelper = $block->getData('reviewHelper');
?>
<?php if ($block->getReviews() && count($block->getReviews())): ?>
<div class="table-wrapper reviews">
<table class="data table table-reviews" id="my-reviews-table">
<caption class="table-caption"><?= $block->escapeHtml(__('Product Reviews')) ?></caption>
<caption class="table-caption"><?= $escaper->escapeHtml(__('Product Reviews')) ?></caption>
<thead>
<tr>
<th scope="col" class="col date"><?= $block->escapeHtml(__('Created')) ?></th>
<th scope="col" class="col item"><?= $block->escapeHtml(__('Product Name')) ?></th>
<th scope="col" class="col summary"><?= $block->escapeHtml(__('Rating')) ?></th>
<th scope="col" class="col description"><?= $block->escapeHtml(__('Review')) ?></th>
<th scope="col" class="col date"><?= $escaper->escapeHtml(__('Created')) ?></th>
<th scope="col" class="col item"><?= $escaper->escapeHtml(__('Product Name')) ?></th>
<th scope="col" class="col summary"><?= $escaper->escapeHtml(__('Rating')) ?></th>
<th scope="col" class="col description"><?= $escaper->escapeHtml(__('Review')) ?></th>
<th scope="col" class="col actions">&nbsp;</th>
</tr>
</thead>
<tbody>
<?php foreach ($block->getReviews() as $review): ?>
<tr>
<td data-th="<?= $block->escapeHtml(__('Created')) ?>"
class="col date"><?= $block->escapeHtml($block->dateFormat($review->getReviewCreatedAt())) ?>
<td data-th="<?= $escaper->escapeHtml(__('Created')) ?>"
class="col date"><?= $escaper->escapeHtml($block->dateFormat($review->getReviewCreatedAt())) ?>
</td>
<td data-th="<?= $block->escapeHtml(__('Product Name')) ?>" class="col item">
<td data-th="<?= $escaper->escapeHtml(__('Product Name')) ?>" class="col item">
<strong class="product-name">
<a href="<?= $block->escapeUrl($block->getProductUrl($review)) ?>">
<?= $block->escapeHtml($review->getName()) ?>
<a href="<?= $escaper->escapeUrl($block->getProductUrl($review)) ?>">
<?= $escaper->escapeHtml($review->getName()) ?>
</a>
</strong>
</td>
<td data-th="<?= $block->escapeHtml(__('Rating')) ?>" class="col summary">
<td data-th="<?= $escaper->escapeHtml(__('Rating')) ?>" class="col summary">
<?php if ($review->getSum()): ?>
<div class="rating-summary">
<span class="label"><span><?= $block->escapeHtml(__('Rating')) ?>:</span></span>
<span class="label"><span><?= $escaper->escapeHtml(__('Rating')) ?>:</span></span>
<div class="rating-result"
title="<?= /* @noEscape */ ((int)$review->getSum() / (int)$review->getCount()) ?>%">
<span>
Expand All @@ -57,12 +57,12 @@ $reviewHelper = $block->getData('reviewHelper');
) ?>
<?php endif; ?>
</td>
<td data-th="<?= $block->escapeHtmlAttr(__('Review')) ?>" class="col description">
<td data-th="<?= $escaper->escapeHtmlAttr(__('Review')) ?>" class="col description">
<?= $reviewHelper->getDetailHtml($review->getDetail()) ?>
</td>
<td data-th="<?= $block->escapeHtmlAttr(__('Actions')) ?>" class="col actions">
<a href="<?= $block->escapeUrl($block->getReviewUrl($review)) ?>" class="action more">
<span><?= $block->escapeHtml(__('See Details')) ?></span>
<td data-th="<?= $escaper->escapeHtmlAttr(__('Actions')) ?>" class="col actions">
<a href="<?= $escaper->escapeUrl($block->getReviewUrl($review)) ?>" class="action more">
<span><?= $escaper->escapeHtml(__('See Details')) ?></span>
</a>
</td>
</tr>
Expand All @@ -76,12 +76,12 @@ $reviewHelper = $block->getData('reviewHelper');
</div>
<?php endif; ?>
<?php else: ?>
<div class="message info empty"><span><?= $block->escapeHtml(__('You have submitted no reviews.')) ?></span></div>
<div class="message info empty"><span><?= $escaper->escapeHtml(__('You have submitted no reviews.')) ?></span></div>
<?php endif; ?>
<div class="actions-toolbar">
<div class="secondary">
<a class="action back" href="<?= $block->escapeUrl($block->getBackUrl()) ?>">
<span><?= $block->escapeHtml(__('Back')) ?></span>
<a class="action back" href="<?= $escaper->escapeUrl($block->getBackUrl()) ?>">
<span><?= $escaper->escapeHtml(__('Back')) ?></span>
</a>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,38 @@

/**
* @var \Magento\Review\Block\Customer\Recent $block
* @var \Magento\Framework\Escaper $escaper
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
*/
?>
<?php if ($block->getReviews() && count($block->getReviews())): ?>
<div class="block block-reviews-dashboard">
<div class="block-title">
<strong><?= $block->escapeHtml(__('My Recent Reviews')) ?></strong>
<a class="action view" href="<?= $block->escapeUrl($block->getAllReviewsUrl()) ?>">
<span><?= $block->escapeHtml(__('View All')) ?></span>
<strong><?= $escaper->escapeHtml(__('My Recent Reviews')) ?></strong>
<a class="action view" href="<?= $escaper->escapeUrl($block->getAllReviewsUrl()) ?>">
<span><?= $escaper->escapeHtml(__('View All')) ?></span>
</a>
</div>
<div class="block-content">
<ol class="items">
<?php foreach ($block->getReviews() as $_review): ?>
<li class="item">
<strong class="product-name">
<a href="<?= $block->escapeUrl($block->getReviewUrl($_review->getReviewId())) ?>">
<?= $block->escapeHtml($_review->getName()) ?>
<a href="<?= $escaper->escapeUrl($block->getReviewUrl($_review->getReviewId())) ?>">
<?= $escaper->escapeHtml($_review->getName()) ?>
</a>
</strong>
<?php if ($_review->getSum()): ?>
<?php $rating = $_review->getSum() / $_review->getCount() ?>
<div class="rating-summary">
<span class="label"><span><?= $block->escapeHtml(__('Rating')) ?>:</span></span>
<div class="rating-result" title="<?= $block->escapeHtmlAttr($rating) ?>%">
<span class="label"><span><?= $escaper->escapeHtml(__('Rating')) ?>:</span></span>
<div class="rating-result" title="<?= $escaper->escapeHtmlAttr($rating) ?>%">
<span>
<span><?= $block->escapeHtml($rating) ?>%</span>
<span><?= $escaper->escapeHtml($rating) ?>%</span>
</span>
</div>
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
"width:". $block->escapeHtmlAttr($rating) . "%",
"width:". $escaper->escapeHtmlAttr($rating) . "%",
'div.rating-result>span:first-child'
) ?>
</div>
Expand Down
Loading