Skip to content

Commit 088e9f5

Browse files
committed
Merge remote-tracking branch 'origin/B2B-2069' into B2B-2052
2 parents 6e0cc87 + 9a132c5 commit 088e9f5

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

app/code/Magento/AwsS3/Driver/AwsS3.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,19 +295,20 @@ public function readDirectory($path): array
295295
*/
296296
public function getRealPathSafety($path)
297297
{
298+
//Removing redundant directory separators
299+
$path = preg_replace(
300+
'~(?<!:)\/\/+~',
301+
'/',
302+
$path
303+
);
304+
298305
if (strpos($path, '/.') === false) {
299306
return $path;
300307
}
301308

302309
$isAbsolute = strpos($path, $this->normalizeAbsolutePath('')) === 0;
303310
$path = $this->normalizeRelativePath($path);
304311

305-
//Removing redundant directory separators.
306-
$path = preg_replace(
307-
'/\\/\\/+/',
308-
'/',
309-
$path
310-
);
311312
$pathParts = explode('/', $path);
312313
if (end($pathParts) === '.') {
313314
$pathParts[count($pathParts) - 1] = '';

app/code/Magento/AwsS3/Test/Unit/Driver/AwsS3Test.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,18 @@ public function getRealPathSafetyDataProvider(): array
407407
[
408408
'test/test/../test.txt',
409409
'test/test.txt'
410+
],
411+
[
412+
'test//test/../test.txt',
413+
'test/test.txt'
414+
],
415+
[
416+
'test1///test2/..//test3//test.txt',
417+
'test1/test3/test.txt'
418+
],
419+
[
420+
self::URL . '/test1///test2/..//test3//test.txt',
421+
self::URL . 'test1/test3/test.txt'
410422
]
411423
];
412424
}

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/ImagesTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ private function assertSuccessfulImageSave(array $expectation): void
138138
$this->assertEquals($expectation['small_image'], $product->getData('small_image'));
139139
$this->assertEquals($expectation['thumbnail'], $product->getData('thumbnail'));
140140
$this->assertEquals($expectation['swatch_image'], $product->getData('swatch_image'));
141-
$this->assertFileExists(
142-
$this->mediaDirectory->getAbsolutePath($this->config->getBaseMediaPath() . $expectation['image'])
141+
$this->assertTrue(
142+
$this->mediaDirectory->isExist(
143+
$this->mediaDirectory->getAbsolutePath($this->config->getBaseMediaPath() . $expectation['image'])
144+
)
143145
);
144146
}
145147
}

0 commit comments

Comments
 (0)