Skip to content

Commit

Permalink
Merge pull request #4359 from magento-obsessive-owls/MC-16618
Browse files Browse the repository at this point in the history
[Owls] Eliminate @escapeNotVerified in Sales-related Modules
  • Loading branch information
davemacaulay authored Jun 18, 2019
2 parents b223107 + cfd13de commit 42e7576
Show file tree
Hide file tree
Showing 129 changed files with 1,782 additions and 1,914 deletions.
12 changes: 7 additions & 5 deletions app/code/Magento/AdminNotification/Model/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Magento\AdminNotification\Model;

use Magento\Framework\Escaper;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Config\ConfigOptionsListConstants;

/**
Expand All @@ -26,7 +28,7 @@ class Feed extends \Magento\Framework\Model\AbstractModel
const XML_LAST_UPDATE_PATH = 'system/adminnotification/last_update';

/**
* @var \Magento\Framework\Escaper
* @var Escaper
*/
private $escaper;

Expand Down Expand Up @@ -82,7 +84,7 @@ class Feed extends \Magento\Framework\Model\AbstractModel
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
* @param \Magento\Framework\Escaper|null $escaper
* @param Escaper|null $escaper
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -97,7 +99,7 @@ public function __construct(
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = [],
\Magento\Framework\Escaper $escaper = null
Escaper $escaper = null
) {
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
$this->_backendConfig = $backendConfig;
Expand All @@ -106,8 +108,8 @@ public function __construct(
$this->_deploymentConfig = $deploymentConfig;
$this->productMetadata = $productMetadata;
$this->urlBuilder = $urlBuilder;
$this->escaper = $escaper ?? \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\Escaper::class
$this->escaper = $escaper ?? ObjectManager::getInstance()->get(
Escaper::class
);
}

Expand Down
8 changes: 5 additions & 3 deletions app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
*/
namespace Magento\Catalog\Block\Adminhtml\Product;

use Magento\Framework\Escaper;

/**
* Class Edit
*/
class Edit extends \Magento\Backend\Block\Widget
{
/**
* @var \Magento\Framework\Escaper
* @var Escaper
*/
private $escaper;

Expand Down Expand Up @@ -55,7 +57,7 @@ class Edit extends \Magento\Backend\Block\Widget
* @param \Magento\Eav\Model\Entity\Attribute\SetFactory $attributeSetFactory
* @param \Magento\Framework\Registry $registry
* @param \Magento\Catalog\Helper\Product $productHelper
* @param \Magento\Framework\Escaper $escaper
* @param Escaper $escaper
* @param array $data
*/
public function __construct(
Expand All @@ -64,7 +66,7 @@ public function __construct(
\Magento\Eav\Model\Entity\Attribute\SetFactory $attributeSetFactory,
\Magento\Framework\Registry $registry,
\Magento\Catalog\Helper\Product $productHelper,
\Magento\Framework\Escaper $escaper,
Escaper $escaper,
array $data = []
) {
$this->_productHelper = $productHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<testCaseId value="MC-14715"/>
<severity value="CRITICAL"/>
<group value="mtf_migrated"/>
<skip>
<issueId value="MC-16684"/>
</skip>
</annotations>

<before>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<testCaseId value="MC-14719"/>
<severity value="CRITICAL"/>
<group value="mtf_migrated"/>
<skip>
<issueId value="MC-16684"/>
</skip>
</annotations>

<before>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<testCaseId value="MC-14716"/>
<severity value="CRITICAL"/>
<group value="mtf_migrated"/>
<skip>
<issueId value="MC-16684"/>
</skip>
</annotations>

<before>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<testCaseId value="MC-14728"/>
<severity value="CRITICAL"/>
<group value="mtf_migrated"/>
<skip>
<issueId value="MC-16684"/>
</skip>
</annotations>

<before>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
*/
namespace Magento\Customer\Block\Adminhtml\Edit\Tab\Newsletter\Grid\Renderer;

use Magento\Framework\Escaper;
use Magento\Framework\App\ObjectManager;

/**
* Adminhtml newsletter queue grid block action item renderer
*/
class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
{
/**
* @var \Magento\Framework\Escaper
* @var Escaper
*/
private $escaper;

Expand All @@ -26,17 +29,17 @@ class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstract
* @param \Magento\Backend\Block\Context $context
* @param \Magento\Framework\Registry $registry
* @param array $data
* @param \Magento\Framework\Escaper|null $escaper
* @param Escaper|null $escaper
*/
public function __construct(
\Magento\Backend\Block\Context $context,
\Magento\Framework\Registry $registry,
array $data = [],
\Magento\Framework\Escaper $escaper = null
Escaper $escaper = null
) {
$this->_coreRegistry = $registry;
$this->escaper = $escaper ?? \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\Escaper::class
$this->escaper = $escaper ?? ObjectManager::getInstance()->get(
Escaper::class
);
parent::__construct($context, $data);
}
Expand Down
12 changes: 7 additions & 5 deletions app/code/Magento/Customer/Model/Address/Validator/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Magento\Customer\Model\Address\ValidatorInterface;
use Magento\Directory\Helper\Data;
use Magento\Directory\Model\AllowedCountries;
use Magento\Framework\Escaper;
use Magento\Framework\App\ObjectManager;
use Magento\Store\Model\ScopeInterface;

/**
Expand All @@ -17,7 +19,7 @@
class Country implements ValidatorInterface
{
/**
* @var \Magento\Framework\Escaper
* @var Escaper
*/
private $escaper;

Expand All @@ -34,17 +36,17 @@ class Country implements ValidatorInterface
/**
* @param Data $directoryData
* @param AllowedCountries $allowedCountriesReader
* @param \Magento\Framework\Escaper|null $escaper
* @param Escaper|null $escaper
*/
public function __construct(
Data $directoryData,
AllowedCountries $allowedCountriesReader,
\Magento\Framework\Escaper $escaper = null
Escaper $escaper = null
) {
$this->directoryData = $directoryData;
$this->allowedCountriesReader = $allowedCountriesReader;
$this->escaper = $escaper ?? \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\Escaper::class
$this->escaper = $escaper ?? ObjectManager::getInstance()->get(
Escaper::class
);
}

Expand Down
18 changes: 11 additions & 7 deletions app/code/Magento/Directory/Model/ResourceModel/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
*/
namespace Magento\Directory\Model\ResourceModel;

use Magento\Framework\Model\ResourceModel\Db\Context;
use Magento\Framework\Escaper;
use Magento\Framework\App\ObjectManager;

/**
* Country Resource Model
*
Expand All @@ -14,22 +18,22 @@
class Country extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* @var \Magento\Framework\Escaper
* @var Escaper
*/
private $escaper;

/**
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
* @param Context $context
* @param null|string $connectionName
* @param \Magento\Framework\Escaper|null $escaper
* @param Escaper|null $escaper
*/
public function __construct(
\Magento\Framework\Model\ResourceModel\Db\Context $context,
Context $context,
?string $connectionName = null,
\Magento\Framework\Escaper $escaper = null
Escaper $escaper = null
) {
$this->escaper = $escaper ?? \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\Escaper::class
$this->escaper = $escaper ?? ObjectManager::getInstance()->get(
Escaper::class
);
parent::__construct($context, $connectionName);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Reports/Block/Adminhtml/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid
* @param Data $backendHelper
* @param array $data
* @param DecoderInterface|null $urlDecoder
* @param Parameters $parameters
* @param Parameters|null $parameters
*/
public function __construct(
Context $context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,32 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

// phpcs:disable Magento2.Templates.ThisInTemplate
?>
<?php
/**
* @see \Magento\Sales\Block\Adminhtml\Items\Column\Name
*/
/* @var $block \Magento\Sales\Block\Adminhtml\Items\Column\Name */
?>

<?php if ($_item = $block->getItem()): ?>
<div id="order_item_<?= $block->escapeHtml($_item->getId()) ?>_title"
<?php if ($_item = $block->getItem()) : ?>
<div id="order_item_<?= (int) $_item->getId() ?>_title"
class="product-title">
<?= $block->escapeHtml($_item->getName()) ?>
</div>
<div class="product-sku-block">
<span><?= $block->escapeHtml(__('SKU'))?>:</span> <?= implode('<br />', $this->helper('Magento\Catalog\Helper\Data')->splitSku($block->escapeHtml($block->getSku()))) ?>
<span><?= $block->escapeHtml(__('SKU'))?>:</span> <?= /* @noEscape */ implode('<br />', $this->helper(\Magento\Catalog\Helper\Data::class)->splitSku($block->escapeHtml($block->getSku()))) ?>
</div>

<?php if ($block->getOrderOptions()): ?>
<?php if ($block->getOrderOptions()) : ?>
<dl class="item-options">
<?php foreach ($block->getOrderOptions() as $_option): ?>
<?php foreach ($block->getOrderOptions() as $_option) : ?>
<dt><?= $block->escapeHtml($_option['label']) ?>:</dt>
<dd>
<?php if (isset($_option['custom_view']) && $_option['custom_view']): ?>
<?= /* @escapeNotVerified */ $block->getCustomizedOptionValue($_option) ?>
<?php else: ?>
<?php if (isset($_option['custom_view']) && $_option['custom_view']) : ?>
<?= /* @noEscape */ $block->getCustomizedOptionValue($_option) ?>
<?php else : ?>
<?php $_option = $block->getFormattedOption($_option['value']); ?>
<?php $dots = 'dots' . uniqid(); ?>
<?= $block->escapeHtml($_option['value']) ?><?php if (isset($_option['remainder']) && $_option['remainder']): ?> <span id="<?= /* @noEscape */ $dots; ?>"> ...</span>
<?php $id = 'id' . uniqid(); ?>
<?= $block->escapeHtml($_option['value']) ?><?php if (isset($_option['remainder']) && $_option['remainder']) : ?> <span id="<?= /* @noEscape */ $dots; ?>"> ...</span>
<?php $id = 'id' . uniqid(); ?>
<span id="<?= /* @noEscape */ $id; ?>"><?= $block->escapeHtml($_option['remainder']) ?></span>
<script>
require(['prototype'], function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,41 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

?>
<?php if ($item = $block->getItem()): ?>
<table class="qty-table">
<tr>
<th><?= $block->escapeHtml(__('Ordered')); ?></th>
<td><?= /* @noEscape */ $item->getQtyOrdered()*1 ?></td>
</tr>

<?php if ((float) $item->getQtyInvoiced()): ?>
<?php if ($item = $block->getItem()) : ?>
<table class="qty-table">
<tr>
<th><?= $block->escapeHtml(__('Invoiced')); ?></th>
<td><?= /* @noEscape */ $item->getQtyInvoiced()*1 ?></td>
<th><?= $block->escapeHtml(__('Ordered')); ?></th>
<td><?= (int) $item->getQtyOrdered() ?></td>
</tr>
<?php endif; ?>

<?php if ((float) $item->getQtyShipped()): ?>
<tr>
<th><?= $block->escapeHtml(__('Shipped')); ?></th>
<td><?= /* @noEscape */ $item->getQtyShipped()*1 ?></td>
</tr>
<?php endif; ?>
<?php if ((float)$item->getQtyInvoiced()) : ?>
<tr>
<th><?= $block->escapeHtml(__('Invoiced')); ?></th>
<td><?= (int) $item->getQtyInvoiced() ?></td>
</tr>
<?php endif; ?>

<?php if ((float) $item->getQtyRefunded()): ?>
<tr>
<th><?= $block->escapeHtml(__('Refunded')); ?></th>
<td><?= /* @noEscape */ $item->getQtyRefunded()*1 ?></td>
</tr>
<?php endif; ?>
<?php if ((float)$item->getQtyShipped()) : ?>
<tr>
<th><?= $block->escapeHtml(__('Shipped')); ?></th>
<td><?= (int) $item->getQtyShipped() ?></td>
</tr>
<?php endif; ?>

<?php if ((float) $item->getQtyCanceled()): ?>
<tr>
<th><?= $block->escapeHtml(__('Canceled')); ?></th>
<td><?= /* @noEscape */ $item->getQtyCanceled()*1 ?></td>
</tr>
<?php endif; ?>
<?php if ((float)$item->getQtyRefunded()) : ?>
<tr>
<th><?= $block->escapeHtml(__('Refunded')); ?></th>
<td><?= (int) $item->getQtyRefunded() ?></td>
</tr>
<?php endif; ?>

<?php if ((float)$item->getQtyCanceled()) : ?>
<tr>
<th><?= $block->escapeHtml(__('Canceled')); ?></th>
<td><?= (int) $item->getQtyCanceled() ?></td>
</tr>
<?php endif; ?>

</table>
</table>
<?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

?>
<?php
/** @var \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $block */

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

<div class="price-excl-tax">
<?= /* @escapeNotVerified */ $block->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?>
<?= /* @noEscape */ $block->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?>
</div>
Loading

0 comments on commit 42e7576

Please sign in to comment.