Skip to content

Commit d0def5d

Browse files
authored
Merge branch '2.4-develop' into patch-1
2 parents ae3193a + a9f88e2 commit d0def5d

File tree

31 files changed

+513
-121
lines changed

31 files changed

+513
-121
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product.php

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\CatalogImportExport\Model\Import;
88

9+
use Magento\AwsS3\Driver\AwsS3;
910
use Magento\Catalog\Api\ProductRepositoryInterface;
1011
use Magento\Catalog\Model\Config as CatalogConfig;
1112
use Magento\Catalog\Model\Indexer\Product\Category as ProductCategoryIndexer;
@@ -2309,6 +2310,14 @@ protected function _getUploader()
23092310

23102311
$tmpPath = $this->getImportDir();
23112312

2313+
if (is_a($this->_mediaDirectory->getDriver(), AwsS3::class)) {
2314+
if (!$this->_mediaDirectory->create($tmpPath)) {
2315+
throw new LocalizedException(
2316+
__('Directory \'%1\' could not be created.', $tmpPath)
2317+
);
2318+
}
2319+
}
2320+
23122321
if (!$fileUploader->setTmpDir($tmpPath)) {
23132322
throw new LocalizedException(
23142323
__('File directory \'%1\' is not readable.', $tmpPath)

app/code/Magento/CatalogImportExport/composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"magento/module-media-storage": "*",
1818
"magento/module-store": "*",
1919
"magento/module-tax": "*",
20-
"magento/module-authorization": "*"
20+
"magento/module-authorization": "*",
21+
"magento/module-aws-s3": "*"
2122
},
2223
"type": "magento2-module",
2324
"license": [

app/code/Magento/Config/Block/System/Config/Form/Field/File.php

100644100755
+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
*
1010
* @author Magento Core Team <[email protected]>
1111
*/
12+
declare(strict_types=1);
13+
1214
namespace Magento\Config\Block\System\Config\Form\Field;
1315

1416
class File extends \Magento\Framework\Data\Form\Element\File
@@ -35,7 +37,7 @@ protected function _getDeleteCheckbox()
3537
$html = '';
3638
if ((string)$this->getValue()) {
3739
$label = __('Delete File');
38-
$html .= '<div>' . $this->getValue() . ' ';
40+
$html .= '<div>' . $this->_escaper->escapeHtml($this->getValue()) . ' ';
3941
$html .= '<input type="checkbox" name="' .
4042
parent::getName() .
4143
'[delete]" value="1" class="checkbox" id="' .

app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/FileTest.php

+62-19
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,85 @@
88
namespace Magento\Config\Test\Unit\Block\System\Config\Form\Field;
99

1010
use Magento\Config\Block\System\Config\Form\Field\File;
11+
use Magento\Framework\Data\Form\Element\Factory;
12+
use Magento\Framework\Data\Form\Element\CollectionFactory;
1113
use Magento\Framework\DataObject;
1214
use Magento\Framework\Escaper;
1315
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
16+
use PHPUnit\Framework\MockObject\MockObject;
1417
use PHPUnit\Framework\TestCase;
1518

1619
/**
1720
* Tests for \Magento\Framework\Data\Form\Field\File
1821
*/
1922
class FileTest extends TestCase
2023
{
24+
/**
25+
* XSS value
26+
*/
27+
private const XSS_FILE_NAME_TEST = '<img src=x onerror=alert(1)>.crt';
28+
29+
/**
30+
* Input name
31+
*/
32+
private const INPUT_NAME_TEST = 'test_name';
33+
2134
/**
2235
* @var File
2336
*/
2437
protected $file;
2538

39+
/**
40+
* @var Factory|MockObject
41+
*/
42+
private $factoryMock;
43+
44+
/**
45+
* @var CollectionFactory|MockObject
46+
*/
47+
private $factoryCollectionMock;
48+
49+
/**
50+
* @var Escaper|MockObject
51+
*/
52+
private $escaperMock;
53+
2654
/**
2755
* @var array
2856
*/
29-
protected $testData;
57+
protected array $testData = [
58+
'before_element_html' => 'test_before_element_html',
59+
'html_id' => 'test_id',
60+
'name' => 'test_name',
61+
'value' => 'test_value',
62+
'title' => 'test_title',
63+
'disabled' => true,
64+
'after_element_js' => 'test_after_element_js',
65+
'after_element_html' => 'test_after_element_html',
66+
'html_id_prefix' => 'test_id_prefix_',
67+
'html_id_suffix' => '_test_id_suffix',
68+
];
3069

3170
protected function setUp(): void
3271
{
3372
$objectManager = new ObjectManager($this);
3473

35-
$this->testData = [
36-
'before_element_html' => 'test_before_element_html',
37-
'html_id' => 'test_id',
38-
'name' => 'test_name',
39-
'value' => 'test_value',
40-
'title' => 'test_title',
41-
'disabled' => true,
42-
'after_element_js' => 'test_after_element_js',
43-
'after_element_html' => 'test_after_element_html',
44-
'html_id_prefix' => 'test_id_prefix_',
45-
'html_id_suffix' => '_test_id_suffix',
46-
];
47-
74+
$this->factoryMock = $this->getMockBuilder(Factory::class)
75+
->disableOriginalConstructor()
76+
->getMock();
77+
$this->factoryCollectionMock = $this->getMockBuilder(CollectionFactory::class)
78+
->disableOriginalConstructor()
79+
->getMock();
80+
$this->escaperMock = $this->getMockBuilder(Escaper::class)
81+
->disableOriginalConstructor()
82+
->getMock();
4883
$this->file = $objectManager->getObject(
4984
File::class,
5085
[
51-
'_escaper' => $objectManager->getObject(Escaper::class),
86+
'factoryElement' => $this->factoryMock,
87+
'factoryCollection' => $this->factoryCollectionMock,
88+
'_escaper' => $this->escaperMock,
5289
'data' => $this->testData,
53-
5490
]
5591
);
5692

@@ -60,13 +96,20 @@ protected function setUp(): void
6096
$this->file->setForm($formMock);
6197
}
6298

63-
public function testGetElementHtml()
99+
public function testGetElementHtml(): void
64100
{
65-
$html = $this->file->getElementHtml();
66-
67101
$expectedHtmlId = $this->testData['html_id_prefix']
68102
. $this->testData['html_id']
69103
. $this->testData['html_id_suffix'];
104+
$this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnMap(
105+
[
106+
[$expectedHtmlId, null, $expectedHtmlId],
107+
[self::XSS_FILE_NAME_TEST, null, self::XSS_FILE_NAME_TEST],
108+
[self::INPUT_NAME_TEST, null, self::INPUT_NAME_TEST],
109+
]
110+
);
111+
112+
$html = $this->file->getElementHtml();
70113

71114
$this->assertStringContainsString('<label class="addbefore" for="' . $expectedHtmlId . '"', $html);
72115
$this->assertStringContainsString($this->testData['before_element_html'], $html);

app/code/Magento/ConfigurableProduct/etc/adminhtml/di.xml

+3
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,7 @@
8181
<type name="Magento\Sales\Model\Order\Invoice">
8282
<plugin name="update_configurable_product_total_qty" type="Magento\ConfigurableProduct\Plugin\Model\Order\Invoice\UpdateConfigurableProductTotalQty"/>
8383
</type>
84+
<type name="Magento\CatalogWidget\Block\Product\ProductsList">
85+
<plugin name="configurable_product_widget_product_list" type="Magento\ConfigurableProduct\Plugin\CatalogWidget\Block\Product\ProductsListPlugin" sortOrder="2"/>
86+
</type>
8487
</config>

app/code/Magento/ConfigurableProduct/etc/di.xml

-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
<preference for="Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price\OptionsSelectBuilderInterface" type="Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price\OptionsSelectBuilder" />
2222
<preference for="Magento\ConfigurableProduct\Pricing\Price\ConfigurableOptionsFilterInterface" type="Magento\ConfigurableProduct\Pricing\Price\ConfigurableOptionsCompositeFilter" />
2323

24-
<type name="Magento\CatalogWidget\Block\Product\ProductsList">
25-
<plugin name="configurable_product_widget_product_list" type="Magento\ConfigurableProduct\Plugin\CatalogWidget\Block\Product\ProductsListPlugin" sortOrder="2"/>
26-
</type>
2724
<type name="Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\Initializer\Option">
2825
<plugin name="configurable_product" type="Magento\ConfigurableProduct\Model\Quote\Item\QuantityValidator\Initializer\Option\Plugin\ConfigurableProduct" sortOrder="50" />
2926
</type>

app/code/Magento/ConfigurableProduct/etc/frontend/di.xml

+3
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@
2323
</argument>
2424
</arguments>
2525
</type>
26+
<type name="Magento\CatalogWidget\Block\Product\ProductsList">
27+
<plugin name="configurable_product_widget_product_list" type="Magento\ConfigurableProduct\Plugin\CatalogWidget\Block\Product\ProductsListPlugin" sortOrder="2"/>
28+
</type>
2629
</config>

app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,16 @@ function (array $args) {
138138
*/
139139
public function getOutputFormatDataProvider(): array
140140
{
141+
$ar_DZ = "\u{062C}.\u{0645}.\u{200F}\u{00A0}%s";
142+
if (version_compare(PHP_VERSION, '8.3', '>=')) {
143+
$ar_DZ = "%s\u{00A0}\u{062C}.\u{0645}.\u{200F}";
144+
}
141145
return [
142146
'en_US:USD' => ['en_US', 'USD', '$%s'],
143147
'en_US:PLN' => ['en_US', 'PLN', "PLN\u{00A0}%s"],
144148
'en_US:PKR' => ['en_US', 'PKR', "PKR\u{00A0}%s"],
145149
'af_ZA:VND' => ['af_ZA', 'VND', "\u{20AB}%s"],
146-
'ar_DZ:EGP' => ['ar_DZ', 'EGP', "\u{062C}.\u{0645}.\u{200F}\u{00A0}%s"],
150+
'ar_DZ:EGP' => ['ar_DZ', 'EGP', $ar_DZ],
147151
'ar_SA:USD' => ['ar_SA', 'USD', "%s\u{00A0}US$"],
148152
'ar_SA:LBP' => ['ar_SA', 'LBP', "%s\u{00A0}\u{0644}.\u{0644}.\u{200F}"],
149153
'fa_IR:USD' => ['fa_IR', 'USD', "\u{200E}$%s"],

app/code/Magento/DownloadableImportExport/Helper/Uploader.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\DownloadableImportExport\Helper;
77

88
use Magento\Framework\App\Filesystem\DirectoryList;
9+
use Magento\Framework\Exception\LocalizedException;
910
use Magento\Framework\Filesystem\Driver\File;
1011

1112
/**
@@ -76,7 +77,7 @@ public function __construct(
7677
* @param string $type
7778
* @param array $parameters
7879
* @return \Magento\CatalogImportExport\Model\Import\Uploader
79-
* @throws \Magento\Framework\Exception\LocalizedException
80+
* @throws LocalizedException
8081
*/
8182
public function getUploader($type, $parameters)
8283
{
@@ -94,8 +95,14 @@ public function getUploader($type, $parameters)
9495
$tmpPath = $dirAddon . '/' . $this->mediaDirectory->getRelativePath('import');
9596
}
9697

98+
if (!$this->mediaDirectory->create($tmpPath)) {
99+
throw new LocalizedException(
100+
__('Directory \'%1\' could not be created.', $tmpPath)
101+
);
102+
}
103+
97104
if (!$this->fileUploader->setTmpDir($tmpPath)) {
98-
throw new \Magento\Framework\Exception\LocalizedException(
105+
throw new LocalizedException(
99106
__('File directory \'%1\' is not readable.', $tmpPath)
100107
);
101108
}
@@ -104,7 +111,7 @@ public function getUploader($type, $parameters)
104111

105112
$this->mediaDirectory->create($destinationPath);
106113
if (!$this->fileUploader->setDestDir($destinationPath)) {
107-
throw new \Magento\Framework\Exception\LocalizedException(
114+
throw new LocalizedException(
108115
__('File directory \'%1\' is not writable.', $destinationPath)
109116
);
110117
}

app/code/Magento/Email/Model/Template/Filter.php

-9
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ class Filter extends Template
8181
*/
8282
protected $_modifiers = ['nl2br' => ''];
8383

84-
/**
85-
* @var string
86-
*/
87-
private const CACHE_KEY_PREFIX = "EMAIL_FILTER_";
88-
8984
/**
9085
* @var bool
9186
*/
@@ -414,10 +409,6 @@ public function blockDirective($construction)
414409
$skipParams = ['class', 'id', 'output'];
415410
$blockParameters = $this->getParameters($construction[2]);
416411

417-
if (isset($blockParameters['cache_key'])) {
418-
$blockParameters['cache_key'] = self::CACHE_KEY_PREFIX . $blockParameters['cache_key'];
419-
}
420-
421412
$block = null;
422413

423414
if (isset($blockParameters['class'])) {

0 commit comments

Comments
 (0)