Skip to content

Commit f528baf

Browse files
Merge pull request #3577 from magento-qwerty/2.2.8-bugfixes-030119
Fixed issues: - MAGETWO-92728: Fixed wrong admin notifications behavior - MAGETWO-88650: Wrong swatches behavior - MAGETWO-95402: Incorrect send-friend feature flow - MAGETWO-95441: Fixed incorrect sitemap request flow - MAGETWO-88608: Wrong behavior of static content deploy
2 parents 523a83e + 9f8d3a3 commit f528baf

File tree

23 files changed

+770
-994
lines changed

23 files changed

+770
-994
lines changed

app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,18 @@ public function __construct(
3737
*/
3838
public function render(\Magento\Framework\DataObject $row)
3939
{
40-
$readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' . $row->getUrl() . '">' .
40+
$readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' .
41+
$this->escapeUrl($row->getUrl())
42+
. '">' .
4143
__('Read Details') . '</a>' : '';
4244

43-
$markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' . $this->getUrl(
44-
'*/*/markAsRead/',
45-
['_current' => true, 'id' => $row->getId()]
46-
) . '">' . __(
47-
'Mark as Read'
48-
) . '</a>' : '';
45+
$markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' .
46+
$this->getUrl(
47+
'*/*/markAsRead/',
48+
['_current' => true, 'id' => $row->getId()]
49+
) . '">' . __(
50+
'Mark as Read'
51+
) . '</a>' : '';
4952

5053
$encodedUrl = $this->_urlHelper->getEncodedUrl();
5154
return sprintf(

app/code/Magento/Checkout/view/frontend/templates/cart/item/default.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ $canApplyMsrp = $helper->isShowBeforeOrderConfirm($product) && $helper->isMinima
4949
<?php if (isset($_formatedOptionValue['full_view'])): ?>
5050
<?= /* @escapeNotVerified */ $_formatedOptionValue['full_view'] ?>
5151
<?php else: ?>
52-
<?= /* @escapeNotVerified */ $_formatedOptionValue['value'] ?>
52+
<?= $block->escapeHtml($_formatedOptionValue['value'], ['span']) ?>
5353
<?php endif; ?>
5454
</dd>
5555
<?php endforeach; ?>

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/view/adminhtml/web/js/components/dynamic-rows-configurable.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
define([
77
'underscore',
88
'uiRegistry',
9-
'Magento_Ui/js/dynamic-rows/dynamic-rows'
10-
], function (_, registry, dynamicRows) {
9+
'Magento_Ui/js/dynamic-rows/dynamic-rows',
10+
'jquery'
11+
], function (_, registry, dynamicRows, $) {
1112
'use strict';
1213

1314
return dynamicRows.extend({
@@ -217,6 +218,8 @@ define([
217218

218219
_.each(tmpData, function (row, index) {
219220
path = this.dataScope + '.' + this.index + '.' + (this.startIndex + index);
221+
row.attributes = $('<i></i>').text(row.attributes).html();
222+
row.sku = $('<i></i>').text(row.sku).html();
220223
this.source.set(path, row);
221224
}, this);
222225

@@ -376,8 +379,8 @@ define([
376379
product = {
377380
'id': row.productId,
378381
'product_link': row.productUrl,
379-
'name': row.name,
380-
'sku': row.sku,
382+
'name': $('<i></i>').text(row.name).html(),
383+
'sku': $('<i></i>').text(row.sku).html(),
381384
'status': row.status,
382385
'price': row.price,
383386
'price_currency': row.priceCurrency,

app/code/Magento/Deploy/Console/InputValidator.php

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
*/
66
namespace Magento\Deploy\Console;
77

8-
use Magento\Setup\Console\Command\DeployStaticContentCommand;
8+
use Magento\Framework\App\ObjectManager;
99
use Magento\Deploy\Console\DeployStaticOptions as Options;
1010
use Magento\Framework\Validator\Locale;
1111
use Symfony\Component\Console\Input\InputInterface;
12+
use Magento\Framework\Validator\RegexFactory;
1213

1314
/**
1415
* Command input arguments validator class
@@ -55,21 +56,32 @@ class InputValidator
5556
*/
5657
private $localeValidator;
5758

59+
/**
60+
* @var RegexFactory
61+
*/
62+
private $versionValidatorFactory;
63+
5864
/**
5965
* InputValidator constructor
6066
*
6167
* @param Locale $localeValidator
68+
* @param RegexFactory|null $versionValidatorFactory
6269
*/
63-
public function __construct(Locale $localeValidator)
64-
{
70+
public function __construct(
71+
Locale $localeValidator,
72+
RegexFactory $versionValidatorFactory = null
73+
) {
6574
$this->localeValidator = $localeValidator;
75+
$this->versionValidatorFactory = $versionValidatorFactory ?: ObjectManager::getInstance()
76+
->get(RegexFactory::class);
6677
}
6778

6879
/**
6980
* Validate input options
7081
*
7182
* @param InputInterface $input
7283
* @return void
84+
* @throws \InvalidArgumentException
7385
*/
7486
public function validate(InputInterface $input)
7587
{
@@ -85,6 +97,9 @@ public function validate(InputInterface $input)
8597
$input->getArgument(Options::LANGUAGES_ARGUMENT) ?: ['all'],
8698
$input->getOption(Options::EXCLUDE_LANGUAGE)
8799
);
100+
$this->checkVersionInput(
101+
$input->getOption(Options::CONTENT_VERSION) ?: ''
102+
);
88103
}
89104

90105
/**
@@ -147,4 +162,22 @@ private function checkLanguagesInput(array $languagesInclude, array $languagesEx
147162
}
148163
}
149164
}
165+
166+
/**
167+
* @param string $contentVersion
168+
* @throws \InvalidArgumentException
169+
*/
170+
private function checkVersionInput(string $contentVersion)
171+
{
172+
if ($contentVersion) {
173+
$versionValidator = $this->versionValidatorFactory->create(['pattern' => '/^[A-Za-z0-9_.]+$/']);
174+
if (!$versionValidator->isValid($contentVersion)) {
175+
throw new \InvalidArgumentException(__(
176+
'Argument "' .
177+
Options::CONTENT_VERSION
178+
. '" has invalid value, content version should contain only characters, digits and dots'
179+
));
180+
}
181+
}
182+
}
150183
}
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Deploy\Test\Unit\Console;
8+
9+
use Magento\Framework\Validator\Regex;
10+
use Magento\Framework\Validator\RegexFactory;
11+
use PHPUnit\Framework\TestCase;
12+
use Magento\Deploy\Console\InputValidator;
13+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
14+
use Magento\Deploy\Console\DeployStaticOptions as Options;
15+
use Magento\Framework\Validator\Locale;
16+
use Symfony\Component\Console\Input\InputOption;
17+
use Symfony\Component\Console\Input\InputDefinition;
18+
use Symfony\Component\Console\Input\ArrayInput;
19+
use InvalidArgumentException;
20+
use Symfony\Component\Console\Input\InputArgument;
21+
22+
/**
23+
* Class InputValidatorTest
24+
* @package Magento\Deploy\Test\Unit\Console
25+
* * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26+
*/
27+
class InputValidatorTest extends TestCase
28+
{
29+
/**
30+
* @var ObjectManagerHelper
31+
*/
32+
protected $objectManagerHelper;
33+
34+
/**
35+
* @var InputValidator
36+
*/
37+
protected $inputValidator;
38+
39+
/**
40+
* @var Locale
41+
*/
42+
protected $localeValidator;
43+
44+
/**
45+
* @throws \Zend_Validate_Exception
46+
*/
47+
protected function setUp()
48+
{
49+
$this->objectManagerHelper = new ObjectManagerHelper($this);
50+
51+
$regexFactoryMock = $this->getMockBuilder(RegexFactory::class)
52+
->disableOriginalConstructor()
53+
->setMethods(['create'])
54+
->getMock();
55+
56+
$regexObject = new Regex('/^[A-Za-z0-9_.]+$/');
57+
58+
$regexFactoryMock->expects($this->any())->method('create')
59+
->willReturn($regexObject);
60+
61+
$localeObjectMock = $this->getMockBuilder(Locale::class)->setMethods(['isValid'])
62+
->disableOriginalConstructor()
63+
->getMock();
64+
65+
$localeObjectMock->expects($this->any())->method('isValid')
66+
->with('en_US')
67+
->will($this->returnValue(true));
68+
69+
$this->inputValidator = $this->objectManagerHelper->getObject(
70+
InputValidator::class,
71+
[
72+
'localeValidator' => $localeObjectMock,
73+
'versionValidatorFactory' => $regexFactoryMock
74+
]
75+
);
76+
}
77+
78+
/**
79+
* @throws \Zend_Validate_Exception
80+
*/
81+
public function testValidate()
82+
{
83+
$input = $this->getMockBuilder(ArrayInput::class)
84+
->disableOriginalConstructor()
85+
->setMethods(['getOption', 'getArgument'])
86+
->getMock();
87+
88+
$input->expects($this->atLeastOnce())->method('getArgument')->willReturn(['all']);
89+
90+
$input->expects($this->atLeastOnce())->method('getOption')
91+
->willReturnMap(
92+
[
93+
[Options::AREA, ['all']],
94+
[Options::EXCLUDE_AREA, ['none']],
95+
[Options::THEME, ['all']],
96+
[Options::EXCLUDE_THEME, ['none']],
97+
[Options::EXCLUDE_LANGUAGE, ['none']],
98+
[Options::CONTENT_VERSION, '12345']
99+
]
100+
);
101+
102+
/** @noinspection PhpParamsInspection */
103+
$this->inputValidator->validate($input);
104+
}
105+
106+
/**
107+
* @covers \Magento\Deploy\Console\InputValidator::checkAreasInput()
108+
*/
109+
public function testCheckAreasInputException()
110+
{
111+
$options = [
112+
new InputOption(Options::AREA, null, 4, null, ['test']),
113+
new InputOption(Options::EXCLUDE_AREA, null, 4, null, ['test'])
114+
];
115+
116+
$inputDefinition = new InputDefinition($options);
117+
118+
try {
119+
$this->inputValidator->validate(
120+
new ArrayInput([], $inputDefinition)
121+
);
122+
} catch (\Exception $e) {
123+
$this->assertContains('--area (-a) and --exclude-area cannot be used at the same time', $e->getMessage());
124+
$this->assertInstanceOf(InvalidArgumentException::class, $e);
125+
}
126+
}
127+
128+
/**
129+
* @covers \Magento\Deploy\Console\InputValidator::checkThemesInput()
130+
*/
131+
public function testCheckThemesInputException()
132+
{
133+
$options = [
134+
new InputOption(Options::AREA, null, 4, null, ['all']),
135+
new InputOption(Options::EXCLUDE_AREA, null, 4, null, ['none']),
136+
new InputOption(Options::THEME, null, 4, '', ['blank']),
137+
new InputOption(Options::EXCLUDE_THEME, null, 4, '', ['luma'])
138+
];
139+
140+
$inputDefinition = new InputDefinition($options);
141+
142+
try {
143+
$this->inputValidator->validate(
144+
new ArrayInput([], $inputDefinition)
145+
);
146+
} catch (\Exception $e) {
147+
$this->assertContains('--theme (-t) and --exclude-theme cannot be used at the same time', $e->getMessage());
148+
$this->assertInstanceOf(InvalidArgumentException::class, $e);
149+
}
150+
}
151+
152+
public function testCheckLanguagesInputException()
153+
{
154+
$options = [
155+
new InputOption(Options::AREA, null, 4, null, ['all']),
156+
new InputOption(Options::EXCLUDE_AREA, null, 4, null, ['none']),
157+
new InputOption(Options::THEME, null, 4, '', ['all']),
158+
new InputOption(Options::EXCLUDE_THEME, null, 4, '', ['none']),
159+
new InputArgument(Options::LANGUAGES_ARGUMENT, null, 4, ['en_US']),
160+
new InputOption(Options::EXCLUDE_LANGUAGE, null, 4, '', ['all'])
161+
];
162+
163+
$inputDefinition = new InputDefinition($options);
164+
165+
try {
166+
$this->inputValidator->validate(
167+
new ArrayInput([], $inputDefinition)
168+
);
169+
} catch (\Exception $e) {
170+
$this->assertContains(
171+
'--language (-l) and --exclude-language cannot be used at the same time',
172+
$e->getMessage()
173+
);
174+
175+
$this->assertInstanceOf(InvalidArgumentException::class, $e);
176+
}
177+
}
178+
179+
public function testCheckVersionInputException()
180+
{
181+
$options = [
182+
new InputOption(Options::AREA, null, 4, null, ['all']),
183+
new InputOption(Options::EXCLUDE_AREA, null, 4, null, ['none']),
184+
new InputOption(Options::THEME, null, 4, '', ['all']),
185+
new InputOption(Options::EXCLUDE_THEME, null, 4, '', ['none']),
186+
new InputArgument(Options::LANGUAGES_ARGUMENT, null, 4, ['en_US']),
187+
new InputOption(Options::EXCLUDE_LANGUAGE, null, 4, '', ['none']),
188+
new InputOption(Options::CONTENT_VERSION, null, 4, '', '/*!#')
189+
];
190+
191+
$inputDefinition = new InputDefinition($options);
192+
193+
try {
194+
$this->inputValidator->validate(
195+
new ArrayInput([], $inputDefinition)
196+
);
197+
} catch (\Exception $e) {
198+
$this->assertContains(
199+
'Argument "' .
200+
Options::CONTENT_VERSION
201+
. '" has invalid value, content version should contain only characters, digits and dots',
202+
$e->getMessage()
203+
);
204+
205+
$this->assertInstanceOf(InvalidArgumentException::class, $e);
206+
}
207+
}
208+
}

0 commit comments

Comments
 (0)