Skip to content

Commit ef85f81

Browse files
author
Magento CICD
authored
merge magento/develop into magento-earl-grey/MAGETWO-72521
2 parents c57763a + 55e9a5c commit ef85f81

File tree

911 files changed

+59435
-41983
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

911 files changed

+59435
-41983
lines changed

app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
class ListAction extends \Magento\Backend\App\AbstractAction
1010
{
11+
/**
12+
* Authorization level of a basic admin session
13+
*/
14+
const ADMIN_RESOURCE = 'Magento_AdminNotification::show_list';
15+
1116
/**
1217
* @var \Magento\Framework\Json\Helper\Data
1318
*/

app/code/Magento/AdminNotification/Model/Feed.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ public function checkUpdate()
148148
$feedData[] = [
149149
'severity' => (int)$item->severity,
150150
'date_added' => date('Y-m-d H:i:s', $itemPublicationDate),
151-
'title' => (string)$item->title,
152-
'description' => (string)$item->description,
153-
'url' => (string)$item->link,
151+
'title' => $this->escapeString($item->title),
152+
'description' => $this->escapeString($item->description),
153+
'url' => $this->escapeString($item->link),
154154
];
155155
}
156156
}
@@ -246,4 +246,15 @@ public function getFeedXml()
246246

247247
return $xml;
248248
}
249+
250+
/**
251+
* Converts incoming data to string format and escapes special characters.
252+
*
253+
* @param \SimpleXMLElement $data
254+
* @return string
255+
*/
256+
private function escapeString(\SimpleXMLElement $data)
257+
{
258+
return htmlspecialchars((string)$data);
259+
}
249260
}

app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,27 @@ public function testCheckUpdate($callInbox, $curlRequest)
145145
->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
146146
if ($callInbox) {
147147
$this->inboxFactory->expects($this->once())->method('create')
148-
->will(($this->returnValue($this->inboxModel)));
149-
$this->inboxModel->expects($this->once())->method('parse')->will($this->returnSelf());
148+
->will($this->returnValue($this->inboxModel));
149+
$this->inboxModel->expects($this->once())
150+
->method('parse')
151+
->with(
152+
$this->callback(
153+
function ($data) {
154+
$fieldsToCheck = ['title', 'description', 'url'];
155+
return array_reduce(
156+
$fieldsToCheck,
157+
function ($initialValue, $item) use ($data) {
158+
$haystack = $data[0][$item] ?? false;
159+
return $haystack
160+
? $initialValue && !strpos($haystack, '<') && !strpos($haystack, '>')
161+
: true;
162+
},
163+
true
164+
);
165+
}
166+
)
167+
)
168+
->will($this->returnSelf());
150169
} else {
151170
$this->inboxFactory->expects($this->never())->method('create');
152171
$this->inboxModel->expects($this->never())->method('parse');
@@ -196,7 +215,27 @@ public function checkUpdateDataProvider()
196215
</item>
197216
</channel>
198217
</rss>'
199-
]
218+
],
219+
[
220+
true,
221+
// @codingStandardsIgnoreStart
222+
'HEADER
223+
224+
<?xml version="1.0" encoding="utf-8" ?>
225+
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
226+
<channel>
227+
<title>MagentoCommerce</title>
228+
<item>
229+
<title><![CDATA[<script>alert("Hello!");</script>Test Title]]></title>
230+
<link><![CDATA[http://magento.com/feed_url<script>alert("Hello!");</script>]]></link>
231+
<severity>4</severity>
232+
<description><![CDATA[Test <script>alert("Hello!");</script>Description]]></description>
233+
<pubDate>Tue, 20 Jun 2017 13:14:47 UTC</pubDate>
234+
</item>
235+
</channel>
236+
</rss>'
237+
// @codingStandardsIgnoreEnd
238+
],
200239
];
201240
}
202241
}

app/code/Magento/AdminNotification/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<feed_url>notifications.magentocommerce.com/magento2/community/notifications.rss</feed_url>
1313
<popup_url>widgets.magentocommerce.com/notificationPopup</popup_url>
1414
<severity_icons_url>widgets.magentocommerce.com/%s/%s.gif</severity_icons_url>
15-
<use_https>0</use_https>
15+
<use_https>1</use_https>
1616
<frequency>1</frequency>
1717
<last_update>0</last_update>
1818
</adminnotification>

app/code/Magento/AdminNotification/view/adminhtml/ui_component/notification_area.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
</storageConfig>
2525
<updateUrl path="mui/index/render"/>
2626
</settings>
27+
<aclResource>Magento_AdminNotification::show_list</aclResource>
2728
<dataProvider class="Magento\AdminNotification\Ui\Component\DataProvider\DataProvider" name="notification_area_data_source">
2829
<settings>
2930
<requestFieldName>identity</requestFieldName>

app/code/Magento/Authorizenet/Controller/Directpost/Payment/BackendResponse.php

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,48 @@
66
*/
77
namespace Magento\Authorizenet\Controller\Directpost\Payment;
88

9+
use Magento\Authorizenet\Helper\DataFactory;
10+
use Magento\Authorizenet\Model\Directpost;
11+
use Magento\Authorizenet\Model\DirectpostFactory;
12+
use Magento\Framework\App\Action\Context;
13+
use Magento\Framework\Controller\ResultFactory;
14+
use Magento\Framework\Exception\LocalizedException;
15+
use Magento\Framework\Registry;
16+
use Psr\Log\LoggerInterface;
17+
918
class BackendResponse extends \Magento\Authorizenet\Controller\Directpost\Payment
1019
{
20+
/**
21+
* @var LoggerInterface
22+
*/
23+
private $logger;
24+
25+
/**
26+
* @var DirectpostFactory
27+
*/
28+
private $directpostFactory;
29+
30+
/**
31+
* BackendResponse constructor.
32+
*
33+
* @param Context $context
34+
* @param Registry $coreRegistry
35+
* @param DataFactory $dataFactory
36+
* @param DirectpostFactory $directpostFactory
37+
* @param LoggerInterface|null $logger
38+
*/
39+
public function __construct(
40+
Context $context,
41+
Registry $coreRegistry,
42+
DataFactory $dataFactory,
43+
DirectpostFactory $directpostFactory,
44+
LoggerInterface $logger = null
45+
) {
46+
parent::__construct($context, $coreRegistry, $dataFactory);
47+
$this->directpostFactory = $directpostFactory ?: $this->_objectManager->create(DirectpostFactory::class);
48+
$this->logger = $logger ?: $this->_objectManager->get(LoggerInterface::class);
49+
}
50+
1151
/**
1252
* Response action.
1353
* Action for Authorize.net SIM Relay Request.
@@ -16,7 +56,20 @@ class BackendResponse extends \Magento\Authorizenet\Controller\Directpost\Paymen
1656
*/
1757
public function execute()
1858
{
59+
$data = $this->getRequest()->getParams();
60+
/** @var Directpost $paymentMethod */
61+
$paymentMethod = $this->directpostFactory->create();
62+
if (!empty($data['store_id'])) {
63+
$paymentMethod->setStore($data['store_id']);
64+
}
65+
$paymentMethod->setResponseData($data);
66+
try {
67+
$paymentMethod->validateResponse();
68+
} catch (LocalizedException $e) {
69+
$this->logger->critical($e->getMessage());
70+
return $this->_redirect('noroute');
71+
}
1972
$this->_responseAction('adminhtml');
20-
return $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE);
73+
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
2174
}
2275
}

app/code/Magento/Backend/Block/Widget/Grid/Column.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Backend\Block\Widget\Grid;
77

8+
use Magento\Backend\Block\Widget;
89
use Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter;
910

1011
/**
@@ -14,7 +15,7 @@
1415
* @deprecated 100.2.0 in favour of UI component implementation
1516
* @since 100.0.2
1617
*/
17-
class Column extends \Magento\Backend\Block\Widget
18+
class Column extends Widget
1819
{
1920
/**
2021
* Parent grid
@@ -289,12 +290,30 @@ public function getRowField(\Magento\Framework\DataObject $row)
289290
*/
290291
$frameCallback = $this->getFrameCallback();
291292
if (is_array($frameCallback)) {
293+
$this->validateFrameCallback($frameCallback);
292294
$renderedValue = call_user_func($frameCallback, $renderedValue, $row, $this, false);
293295
}
294296

295297
return $renderedValue;
296298
}
297299

300+
/**
301+
* Validate frame callback
302+
*
303+
* @throws \InvalidArgumentException
304+
*
305+
* @param array $callback
306+
* @return void
307+
*/
308+
private function validateFrameCallback(array $callback)
309+
{
310+
if (!is_object($callback[0]) || !$callback[0] instanceof Widget) {
311+
throw new \InvalidArgumentException(
312+
"Frame callback host must be instance of Magento\\Backend\\Block\\Widget"
313+
);
314+
}
315+
}
316+
298317
/**
299318
* Retrieve row column field value for export
300319
*
@@ -314,6 +333,7 @@ public function getRowFieldExport(\Magento\Framework\DataObject $row)
314333
*/
315334
$frameCallback = $this->getFrameCallback();
316335
if (is_array($frameCallback)) {
336+
$this->validateFrameCallback($frameCallback);
317337
$renderedValue = call_user_func($frameCallback, $renderedValue, $row, $this, true);
318338
}
319339

app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class Translate extends \Magento\Backend\App\Action
2020
*/
2121
protected $resultJsonFactory;
2222

23+
/**
24+
* Authorization level of a basic admin session
25+
*/
26+
const ADMIN_RESOURCE = 'Magento_Backend::content_translation';
27+
2328
/**
2429
* @param Action\Context $context
2530
* @param \Magento\Framework\Translate\Inline\ParserInterface $inlineParser

app/code/Magento/Backend/Controller/Adminhtml/Noroute/Index.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,14 @@ public function execute()
3939
$resultPage->addHandle('adminhtml_noroute');
4040
return $resultPage;
4141
}
42+
43+
/**
44+
* Error page should be public accessible. Do not check keys to avoid redirect loop
45+
*
46+
* @return bool
47+
*/
48+
protected function _validateSecretKey()
49+
{
50+
return true;
51+
}
4252
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Backend\Model\Search;
7+
8+
use Magento\Backend\Model\Search\Config\Result\Builder;
9+
use Magento\Config\Model\Config\Structure;
10+
use Magento\Config\Model\Config\Structure\Element\AbstractComposite;
11+
use Magento\Config\Model\Config\Structure\Element\Iterator as ElementIterator;
12+
13+
/**
14+
* Search Config Model
15+
*/
16+
class Config extends \Magento\Framework\DataObject
17+
{
18+
/**
19+
* @var \Magento\Framework\App\Config\ConfigTypeInterface
20+
*/
21+
private $configStructure;
22+
23+
/**
24+
* @var Builder
25+
*/
26+
private $resultBuilder;
27+
28+
/**
29+
* @param Structure $configStructure
30+
* @param Builder $resultBuilder
31+
*/
32+
public function __construct(Structure $configStructure, Builder $resultBuilder)
33+
{
34+
$this->configStructure = $configStructure;
35+
$this->resultBuilder = $resultBuilder;
36+
}
37+
38+
/**
39+
* @param string $query
40+
* @return $this
41+
*/
42+
public function setQuery($query)
43+
{
44+
$this->setData('query', $query);
45+
return $this;
46+
}
47+
48+
/**
49+
* @return string|null
50+
*/
51+
public function getQuery()
52+
{
53+
return $this->getData('query');
54+
}
55+
56+
/**
57+
* @return bool
58+
*/
59+
public function hasQuery()
60+
{
61+
return $this->hasData('query');
62+
}
63+
64+
/**
65+
* @param array $results
66+
* @return $this
67+
*/
68+
public function setResults(array $results)
69+
{
70+
$this->setData('results', $results);
71+
return $this;
72+
}
73+
74+
/**
75+
* @return array|null
76+
*/
77+
public function getResults()
78+
{
79+
return $this->getData('results');
80+
}
81+
82+
/**
83+
* Load search results
84+
*
85+
* @return $this
86+
*/
87+
public function load()
88+
{
89+
$this->findInStructure($this->configStructure->getTabs(), $this->getQuery());
90+
$this->setResults($this->resultBuilder->getAll());
91+
return $this;
92+
}
93+
94+
/**
95+
* @param ElementIterator $structureElementIterator
96+
* @param string $searchTerm
97+
* @param string $pathLabel
98+
* @return void
99+
* @SuppressWarnings(PHPMD.LongVariable)
100+
*/
101+
private function findInStructure(ElementIterator $structureElementIterator, $searchTerm, $pathLabel = '')
102+
{
103+
if (empty($searchTerm)) {
104+
return;
105+
}
106+
foreach ($structureElementIterator as $structureElement) {
107+
if (mb_stripos((string)$structureElement->getLabel(), $searchTerm) !== false) {
108+
$this->resultBuilder->add($structureElement, $pathLabel);
109+
}
110+
$elementPathLabel = $pathLabel . ' / ' . $structureElement->getLabel();
111+
if ($structureElement instanceof AbstractComposite && $structureElement->hasChildren()) {
112+
$this->findInStructure($structureElement->getChildren(), $searchTerm, $elementPathLabel);
113+
}
114+
}
115+
}
116+
}

0 commit comments

Comments
 (0)