Skip to content
This repository was archived by the owner on May 20, 2019. It is now read-only.

Commit 925b018

Browse files
committed
Merge remote-tracking branch 'engcom/async-webapi-1' into async-webapi-2
2 parents 716bf05 + 65a1f8c commit 925b018

File tree

24 files changed

+350
-227
lines changed

24 files changed

+350
-227
lines changed

app/code/Magento/Catalog/Helper/Product/Configuration.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Catalog\Helper\Product;
77

88
use Magento\Framework\App\ObjectManager;
9+
use Magento\Framework\Escaper;
910
use Magento\Framework\Serialize\Serializer\Json;
1011
use Magento\Catalog\Helper\Product\Configuration\ConfigurationInterface;
1112
use Magento\Framework\App\Helper\AbstractHelper;
@@ -43,6 +44,11 @@ class Configuration extends AbstractHelper implements ConfigurationInterface
4344
*/
4445
private $serializer;
4546

47+
/**
48+
* @var Escaper
49+
*/
50+
private $escaper;
51+
4652
/**
4753
* @param \Magento\Framework\App\Helper\Context $context
4854
* @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory
@@ -55,12 +61,14 @@ public function __construct(
5561
\Magento\Catalog\Model\Product\OptionFactory $productOptionFactory,
5662
\Magento\Framework\Filter\FilterManager $filter,
5763
\Magento\Framework\Stdlib\StringUtils $string,
58-
Json $serializer = null
64+
Json $serializer = null,
65+
Escaper $escaper = null
5966
) {
6067
$this->_productOptionFactory = $productOptionFactory;
6168
$this->filter = $filter;
6269
$this->string = $string;
6370
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
71+
$this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class);
6472
parent::__construct($context);
6573
}
6674

@@ -175,7 +183,7 @@ public function getFormattedOptionValue($optionValue, $params = null)
175183
if (isset($optionValue['option_id'])) {
176184
$optionInfo = $optionValue;
177185
if (isset($optionInfo['value'])) {
178-
$optionValue = $optionInfo['value'];
186+
$optionValue = $this->escaper->escapeHtml($optionInfo['value']);
179187
}
180188
} elseif (isset($optionValue['value'])) {
181189
$optionValue = $optionValue['value'];

app/code/Magento/Checkout/view/frontend/web/template/minicart/item/default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<span data-bind="html: option.value.join('<br>')"></span>
4646
<!-- /ko -->
4747
<!-- ko ifnot: Array.isArray(option.value) -->
48-
<span data-bind="html: option.value"></span>
48+
<span data-bind="text: option.value"></span>
4949
<!-- /ko -->
5050
</dd>
5151
<!-- /ko -->

app/code/Magento/Checkout/view/frontend/web/template/summary/item/details.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<dd class="values" data-bind="html: full_view"></dd>
3636
<!-- /ko -->
3737
<!-- ko ifnot: ($data.full_view)-->
38-
<dd class="values" data-bind="html: value"></dd>
38+
<dd class="values" data-bind="text: value"></dd>
3939
<!-- /ko -->
4040
<!-- /ko -->
4141
</dl>

app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,10 @@ protected function getRows()
475475
[
476476
'required-entry' => true,
477477
'max_text_length' => Sku::SKU_MAX_LENGTH,
478-
]
478+
],
479+
],
480+
[
481+
'elementTmpl' => 'Magento_ConfigurableProduct/components/cell-sku',
479482
]
480483
),
481484
'price_container' => $this->getColumn(

app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use Magento\Framework\Json\Helper\Data as JsonHelper;
1818
use Magento\Framework\Locale\CurrencyInterface;
1919
use Magento\Framework\UrlInterface;
20+
use Magento\Framework\App\ObjectManager;
21+
use Magento\Framework\Escaper;
2022

2123
/**
2224
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -83,6 +85,11 @@ class AssociatedProducts
8385
*/
8486
protected $imageHelper;
8587

88+
/**
89+
* @var Escaper
90+
*/
91+
private $escaper;
92+
8693
/**
8794
* @param LocatorInterface $locator
8895
* @param UrlInterface $urlBuilder
@@ -93,6 +100,8 @@ class AssociatedProducts
93100
* @param CurrencyInterface $localeCurrency
94101
* @param JsonHelper $jsonHelper
95102
* @param ImageHelper $imageHelper
103+
* @param Escaper|null $escaper
104+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
96105
*/
97106
public function __construct(
98107
LocatorInterface $locator,
@@ -103,7 +112,8 @@ public function __construct(
103112
VariationMatrix $variationMatrix,
104113
CurrencyInterface $localeCurrency,
105114
JsonHelper $jsonHelper,
106-
ImageHelper $imageHelper
115+
ImageHelper $imageHelper,
116+
Escaper $escaper = null
107117
) {
108118
$this->locator = $locator;
109119
$this->urlBuilder = $urlBuilder;
@@ -114,6 +124,7 @@ public function __construct(
114124
$this->localeCurrency = $localeCurrency;
115125
$this->jsonHelper = $jsonHelper;
116126
$this->imageHelper = $imageHelper;
127+
$this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class);
117128
}
118129

119130
/**
@@ -280,9 +291,9 @@ protected function prepareVariations()
280291
'product_link' => '<a href="' . $this->urlBuilder->getUrl(
281292
'catalog/product/edit',
282293
['id' => $product->getId()]
283-
) . '" target="_blank">' . $product->getName() . '</a>',
294+
) . '" target="_blank">' . $this->escaper->escapeHtml($product->getName()) . '</a>',
284295
'sku' => $product->getSku(),
285-
'name' => $product->getName(),
296+
'name' => $this->escaper->escapeHtml($product->getName()),
286297
'qty' => $this->getProductStockQty($product),
287298
'price' => $price,
288299
'price_string' => $currency->toCurrency(sprintf("%f", $price)),
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<div class="control-table-text">
8+
<span attr="'data-index': index" data-bind="
9+
text: value,
10+
css: {_disabled: disabled}
11+
">
12+
</span>
13+
</div>

app/code/Magento/Sales/view/adminhtml/templates/items/column/name.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<?= /* @escapeNotVerified */ $block->getCustomizedOptionValue($_option) ?>
3333
<?php else: ?>
3434
<?php $_option = $block->getFormattedOption($_option['value']); ?>
35-
<?= /* @escapeNotVerified */ $_option['value'] ?><?php if (isset($_option['remainder']) && $_option['remainder']): ?><span id="<?= /* @escapeNotVerified */ $_dots = 'dots' . uniqid() ?>"> ...</span><span id="<?= /* @escapeNotVerified */ $_id = 'id' . uniqid() ?>"><?= /* @escapeNotVerified */ $_option['remainder'] ?></span>
35+
<?= $block->escapeHtml($_option['value']) ?><?php if (isset($_option['remainder']) && $_option['remainder']): ?><span id="<?= /* @escapeNotVerified */ $_dots = 'dots' . uniqid() ?>"> ...</span><span id="<?= /* @escapeNotVerified */ $_id = 'id' . uniqid() ?>"><?= /* @escapeNotVerified */ $_option['remainder'] ?></span>
3636
<script>
3737
require(['prototype'], function() {
3838
$('<?= /* @escapeNotVerified */ $_id ?>').hide();

app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items/renderer/default.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
<?php if (!$block->getPrintStatus()): ?>
2121
<?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
2222
<dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="tooltip wrapper"<?php endif; ?>>
23-
<?= /* @escapeNotVerified */ $_formatedOptionValue['value'] ?>
23+
<?= $block->escapeHtml($_formatedOptionValue['value']) ?>
2424
<?php if (isset($_formatedOptionValue['full_view'])): ?>
2525
<div class="tooltip content">
2626
<dl class="item options">
2727
<dt><?= $block->escapeHtml($_option['label']) ?></dt>
28-
<dd><?= /* @escapeNotVerified */ $_formatedOptionValue['full_view'] ?></dd>
28+
<dd><?= $block->escapeHtml($_formatedOptionValue['full_view']) ?></dd>
2929
</dl>
3030
</div>
3131
<?php endif; ?>

app/code/Magento/Sales/view/frontend/templates/order/invoice/items/renderer/default.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
<?php if (!$block->getPrintStatus()): ?>
2121
<?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
2222
<dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="tooltip wrapper"<?php endif; ?>>
23-
<?= /* @escapeNotVerified */ $_formatedOptionValue['value'] ?>
23+
<?= $block->escapeHtml($_formatedOptionValue['value']) ?>
2424
<?php if (isset($_formatedOptionValue['full_view'])): ?>
2525
<div class="tooltip content">
2626
<dl class="item options">
2727
<dt><?= $block->escapeHtml($_option['label']) ?></dt>
28-
<dd><?= /* @escapeNotVerified */ $_formatedOptionValue['full_view'] ?></dd>
28+
<dd><?= $block->escapeHtml($_formatedOptionValue['full_view']) ?></dd>
2929
</dl>
3030
</div>
3131
<?php endif; ?>

app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ $_item = $block->getItem();
2020
<?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
2121
<dd>
2222
<?php if (isset($_formatedOptionValue['full_view'])): ?>
23-
<?= /* @escapeNotVerified */ $_formatedOptionValue['full_view'] ?>
23+
<?= $block->escapeHtml($_formatedOptionValue['full_view']) ?>
2424
<?php else: ?>
25-
<?= /* @escapeNotVerified */ $_formatedOptionValue['value'] ?>
25+
<?=$block->escapeHtml($_formatedOptionValue['value']) ?>
2626
<?php endif; ?>
2727
</dd>
2828
<?php else: ?>

app/code/Magento/Sales/view/frontend/templates/order/shipment/items/renderer/default.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
<?php if (!$block->getPrintStatus()): ?>
2020
<?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
2121
<dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="tooltip wrapper"<?php endif; ?>>
22-
<?= /* @escapeNotVerified */ $_formatedOptionValue['value'] ?>
22+
<?= $block->escapeHtml($_formatedOptionValue['value']) ?>
2323
<?php if (isset($_formatedOptionValue['full_view'])): ?>
2424
<div class="tooltip content">
2525
<dl class="item options">
2626
<dt><?= $block->escapeHtml($_option['label']) ?></dt>
27-
<dd><?= /* @escapeNotVerified */ $_formatedOptionValue['full_view'] ?></dd>
27+
<dd><?= $block->escapeHtml($_formatedOptionValue['full_view']) ?></dd>
2828
</dl>
2929
</div>
3030
<?php endif; ?>

app/code/Magento/Ui/Controller/Adminhtml/Export/GridToCsv.php

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Backend\App\Action\Context;
1010
use Magento\Ui\Model\Export\ConvertToCsv;
1111
use Magento\Framework\App\Response\Http\FileFactory;
12+
use Magento\Framework\App\ObjectManager;
13+
use Magento\Ui\Component\MassAction\Filter;
14+
use Psr\Log\LoggerInterface;
1215

1316
/**
1417
* Class Render
@@ -25,19 +28,35 @@ class GridToCsv extends Action
2528
*/
2629
protected $fileFactory;
2730

31+
/**
32+
* @var Filter
33+
*/
34+
private $filter;
35+
36+
/**
37+
* @var LoggerInterface
38+
*/
39+
private $logger;
40+
2841
/**
2942
* @param Context $context
3043
* @param ConvertToCsv $converter
3144
* @param FileFactory $fileFactory
45+
* @param Filter|null $filter
46+
* @param LoggerInterface|null $logger
3247
*/
3348
public function __construct(
3449
Context $context,
3550
ConvertToCsv $converter,
36-
FileFactory $fileFactory
51+
FileFactory $fileFactory,
52+
Filter $filter = null,
53+
LoggerInterface $logger = null
3754
) {
3855
parent::__construct($context);
3956
$this->converter = $converter;
4057
$this->fileFactory = $fileFactory;
58+
$this->filter = $filter ?: ObjectManager::getInstance()->get(Filter::class);
59+
$this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
4160
}
4261

4362
/**
@@ -50,4 +69,32 @@ public function execute()
5069
{
5170
return $this->fileFactory->create('export.csv', $this->converter->getCsvFile(), 'var');
5271
}
72+
73+
/**
74+
* Checking if the user has access to requested component.
75+
*
76+
* @inheritDoc
77+
*/
78+
protected function _isAllowed()
79+
{
80+
if ($this->_request->getParam('namespace')) {
81+
try {
82+
$component = $this->filter->getComponent();
83+
$dataProviderConfig = $component->getContext()
84+
->getDataProvider()
85+
->getConfigData();
86+
if (isset($dataProviderConfig['aclResource'])) {
87+
return $this->_authorization->isAllowed(
88+
$dataProviderConfig['aclResource']
89+
);
90+
}
91+
} catch (\Throwable $exception) {
92+
$this->logger->critical($exception);
93+
94+
return false;
95+
}
96+
}
97+
98+
return true;
99+
}
53100
}

app/code/Magento/Ui/Controller/Adminhtml/Export/GridToXml.php

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Backend\App\Action\Context;
1010
use Magento\Ui\Model\Export\ConvertToXml;
1111
use Magento\Framework\App\Response\Http\FileFactory;
12+
use Magento\Framework\App\ObjectManager;
13+
use Magento\Ui\Component\MassAction\Filter;
14+
use Psr\Log\LoggerInterface;
1215

1316
/**
1417
* Class Render
@@ -25,19 +28,35 @@ class GridToXml extends Action
2528
*/
2629
protected $fileFactory;
2730

31+
/**
32+
* @var Filter
33+
*/
34+
private $filter;
35+
36+
/**
37+
* @var LoggerInterface
38+
*/
39+
private $logger;
40+
2841
/**
2942
* @param Context $context
3043
* @param ConvertToXml $converter
3144
* @param FileFactory $fileFactory
45+
* @param Filter|null $filter
46+
* @param LoggerInterface|null $logger
3247
*/
3348
public function __construct(
3449
Context $context,
3550
ConvertToXml $converter,
36-
FileFactory $fileFactory
51+
FileFactory $fileFactory,
52+
Filter $filter = null,
53+
LoggerInterface $logger = null
3754
) {
3855
parent::__construct($context);
3956
$this->converter = $converter;
4057
$this->fileFactory = $fileFactory;
58+
$this->filter = $filter ?: ObjectManager::getInstance()->get(Filter::class);
59+
$this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
4160
}
4261

4362
/**
@@ -50,4 +69,32 @@ public function execute()
5069
{
5170
return $this->fileFactory->create('export.xml', $this->converter->getXmlFile(), 'var');
5271
}
72+
73+
/**
74+
* Checking if the user has access to requested component.
75+
*
76+
* @inheritDoc
77+
*/
78+
protected function _isAllowed()
79+
{
80+
if ($this->_request->getParam('namespace')) {
81+
try {
82+
$component = $this->filter->getComponent();
83+
$dataProviderConfig = $component->getContext()
84+
->getDataProvider()
85+
->getConfigData();
86+
if (isset($dataProviderConfig['aclResource'])) {
87+
return $this->_authorization->isAllowed(
88+
$dataProviderConfig['aclResource']
89+
);
90+
}
91+
} catch (\Throwable $exception) {
92+
$this->logger->critical($exception);
93+
94+
return false;
95+
}
96+
}
97+
98+
return true;
99+
}
53100
}

app/code/Magento/Variable/Model/Variable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function getVariablesOptionArray($withGroup = false)
153153
foreach ($collection->toOptionArray() as $variable) {
154154
$variables[] = [
155155
'value' => '{{customVar code=' . $variable['value'] . '}}',
156-
'label' => __('%1', $variable['label']),
156+
'label' => __('%1', $this->_escaper->escapeHtml($variable['label'])),
157157
];
158158
}
159159
if ($withGroup && $variables) {

0 commit comments

Comments
 (0)