Skip to content

Commit ec1ff76

Browse files
Merge branch '2.4.2-develop' of https://github.com/magento-commerce/magento2ce into MCLOUD-7366
2 parents 19f9ec0 + 08ba639 commit ec1ff76

File tree

36 files changed

+594
-640
lines changed

36 files changed

+594
-640
lines changed

app/code/Magento/Backend/Model/Auth/Session.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Backend\Model\Auth;
79

810
use Magento\Framework\App\ObjectManager;
@@ -210,7 +212,8 @@ public function prolong()
210212
->setPath($this->sessionConfig->getCookiePath())
211213
->setDomain($this->sessionConfig->getCookieDomain())
212214
->setSecure($this->sessionConfig->getCookieSecure())
213-
->setHttpOnly($this->sessionConfig->getCookieHttpOnly());
215+
->setHttpOnly($this->sessionConfig->getCookieHttpOnly())
216+
->setSameSite($this->sessionConfig->getCookieSameSite());
214217
$this->cookieManager->setPublicCookie($this->getName(), $cookieValue, $cookieMetadata);
215218
}
216219
}

app/code/Magento/Backend/Model/Session/AdminConfig.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function __construct(
8585
$this->setCookiePath($adminPath);
8686
$this->setName($sessionName);
8787
$this->setCookieSecure($this->_httpRequest->isSecure());
88+
$this->setCookieSameSite('Lax');
8889
}
8990

9091
/**
@@ -96,6 +97,7 @@ private function extractAdminPath()
9697
{
9798
$backendApp = $this->backendAppList->getCurrentApp();
9899
$cookiePath = null;
100+
//phpcs:ignore
99101
$baseUrl = parse_url($this->backendUrlFactory->create()->getBaseUrl(), PHP_URL_PATH);
100102
if (!$backendApp) {
101103
$cookiePath = $baseUrl . $this->_frontNameResolver->getFrontName();

app/code/Magento/Backend/Test/Unit/Model/Auth/SessionTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ protected function setUp(): void
8484
->getMock();
8585
$this->sessionConfig = $this->createPartialMock(
8686
\Magento\Framework\Session\Config::class,
87-
['getCookiePath', 'getCookieDomain', 'getCookieSecure', 'getCookieHttpOnly']
87+
[
88+
'getCookiePath',
89+
'getCookieDomain',
90+
'getCookieSecure',
91+
'getCookieHttpOnly',
92+
'getCookieSameSite'
93+
]
8894
);
8995
$this->aclBuilder = $this->getMockBuilder(Builder::class)
9096
->disableOriginalConstructor()
@@ -193,6 +199,9 @@ public function testProlong()
193199
$cookieMetadata->expects($this->once())
194200
->method('setHttpOnly')
195201
->with($httpOnly)->willReturnSelf();
202+
$cookieMetadata->expects($this->once())
203+
->method('setSameSite')
204+
->willReturnSelf();
196205

197206
$this->cookieMetadataFactory->expects($this->once())
198207
->method('createPublicCookieMetadata')
@@ -218,6 +227,9 @@ public function testProlong()
218227
$this->sessionConfig->expects($this->once())
219228
->method('getCookieHttpOnly')
220229
->willReturn($httpOnly);
230+
$this->sessionConfig->expects($this->once())
231+
->method('getCookieSameSite')
232+
->willReturn('Lax');
221233

222234
$this->session->prolong();
223235

@@ -247,7 +259,9 @@ public function testIsAllowed($isUserDefined, $isAclDefined, $isAllowed, $expect
247259
$this->storage->expects($this->once())->method('getUser')->willReturn($userMock);
248260
}
249261
if ($isAclDefined && $isUserDefined) {
262+
// phpstan:ignore
250263
$userMock->expects($this->any())->method('getAclRole')->willReturn($userAclRole);
264+
// phpstan:ignore
251265
$aclMock->expects($this->once())->method('isAllowed')->with($userAclRole)->willReturn($isAllowed);
252266
}
253267

app/code/Magento/Catalog/Model/Product/Gallery/UpdateHandler.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ protected function processDeletedImages($product, array &$images)
8888
foreach ($images as $image) {
8989
if (!empty($image['removed'])) {
9090
if (!empty($image['value_id'])) {
91-
if (preg_match('/\.\.(\\\|\/)/', $image['file'])) {
92-
continue;
93-
}
9491
$recordsToDelete[] = $image['value_id'];
9592
if (!in_array($image['file'], $imagesToNotDelete)) {
9693
$imagesToDelete[] = $image['file'];
@@ -116,7 +113,8 @@ protected function processDeletedImages($product, array &$images)
116113
private function canDeleteImage(string $file): bool
117114
{
118115
$catalogPath = $this->mediaConfig->getBaseMediaPath();
119-
return $this->mediaDirectory->isFile($catalogPath . $file)
116+
$filePath = $this->mediaDirectory->getRelativePath($catalogPath . $file);
117+
return $this->mediaDirectory->isFile($filePath)
120118
&& $this->resourceModel->countImageUses($file) <= 1;
121119
}
122120

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSaveCategoryFormActionGroup.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<scrollToTopOfPage stepKey="scrollToTopOfTheCategoryPage"/>
1818
<click selector="{{AdminMainActionsSection.save}}" stepKey="saveCategory"/>
1919
<waitForElementVisible selector="{{AdminMessagesSection.success}}" stepKey="waitForSuccessMessageAppears"/>
20+
<dontSee selector="{{AdminCategoryMessagesSection.saveCategoryWarningMessage}}" stepKey="dontSeeWarningMessage"/>
2021
<see userInput="You saved the category." selector="{{AdminMessagesSection.success}}" stepKey="assertSuccessMessage"/>
2122
</actionGroup>
2223
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/SaveProductFormActionGroup.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<waitForElementVisible selector="{{AdminProductFormActionSection.saveButton}}" stepKey="waitForSaveProductButton"/>
1818
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveProduct"/>
1919
<waitForElementVisible selector="{{AdminMessagesSection.success}}" stepKey="waitProductSaveSuccessMessage"/>
20+
<dontSee selector="{{AdminProductMessagesSection.saveProductWarningMessage}}" stepKey="dontSeeWarningMessage"/>
2021
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the product." stepKey="seeSaveConfirmation"/>
2122
</actionGroup>
2223
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryMessagesSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<section name="AdminCategoryMessagesSection">
1212
<element name="SuccessMessage" type="text" selector=".message-success"/>
1313
<element name="errorMessage" type="text" selector="//div[@class='message message-error error']"/>
14+
<element name="saveCategoryWarningMessage" type="text" selector=".message-warning"/>
1415
</section>
1516
</sections>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductMessagesSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<section name="AdminProductMessagesSection">
1212
<element name="successMessage" type="text" selector=".message.message-success.success"/>
1313
<element name="errorMessage" type="text" selector=".message.message-error.error"/>
14+
<element name="saveProductWarningMessage" type="text" selector=".message-warning"/>
1415
</section>
1516
</sections>

app/code/Magento/Cms/Helper/Wysiwyg/Images.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
namespace Magento\Cms\Helper\Wysiwyg;
77

88
use Magento\Framework\App\Filesystem\DirectoryList;
9+
use Magento\Framework\Exception\ValidatorException;
910

1011
/**
1112
* Wysiwyg Images Helper.
13+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1214
*/
1315
class Images extends \Magento\Framework\App\Helper\AbstractHelper
1416
{
@@ -64,6 +66,11 @@ class Images extends \Magento\Framework\App\Helper\AbstractHelper
6466
*/
6567
protected $escaper;
6668

69+
/**
70+
* @var \Magento\Framework\Filesystem\Directory\Read
71+
*/
72+
private $_readDirectory;
73+
6774
/**
6875
* Construct
6976
*
@@ -87,6 +94,7 @@ public function __construct(
8794

8895
$this->_directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
8996
$this->_directory->create($this->getStorageRoot());
97+
$this->_readDirectory = $filesystem->getDirectoryReadByPath($this->getStorageRoot());
9098
}
9199

92100
/**
@@ -158,15 +166,18 @@ public function convertPathToId($path)
158166
*
159167
* @param string $id
160168
* @return string
161-
* @throws \InvalidArgumentException When path contains restricted symbols.
169+
* @throws \InvalidArgumentException
162170
*/
163171
public function convertIdToPath($id)
164172
{
165173
if ($id === \Magento\Theme\Helper\Storage::NODE_ROOT) {
166174
return $this->getStorageRoot();
167175
} else {
168176
$path = $this->getStorageRoot() . $this->idDecode($id);
169-
if (preg_match('/\.\.(\\\|\/)/', $path)) {
177+
178+
try {
179+
$this->_readDirectory->getAbsolutePath($path);
180+
} catch (\Exception $e) {
170181
throw new \InvalidArgumentException('Path is invalid');
171182
}
172183

app/code/Magento/Cms/Test/Mftf/ActionGroup/SaveAndCloseCMSBlockWithSplitButtonActionGroup.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<click selector="{{BlockNewPagePageActionsSection.saveAndClose}}" stepKey="clickSaveBlock"/>
1919
<waitForPageLoad stepKey="waitForPageLoadAfterClickingSave"/>
2020
<waitForElementVisible selector="{{AdminMessagesSection.success}}" stepKey="waitForSuccessMessageAppear"/>
21+
<dontSee selector="{{BlockPageActionsSection.saveBlockWarningMessage}}" stepKey="dontSeeWarningMessage"/>
2122
<see userInput="You saved the block." selector="{{AdminMessagesSection.success}}" stepKey="assertSaveBlockSuccessMessage"/>
2223
</actionGroup>
2324
</actionGroups>

0 commit comments

Comments
 (0)