Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 621e245

Browse files
author
Oleksii Korshenko
committed
MAGETWO-67590: Fix filesystem permission issues #5372
- Merge Pull Request magento/magento2#5372 from BlackIkeEagle/magento2:fix-filesystem-permission-issues
2 parents d8a0b12 + abbb03e commit 621e245

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

lib/internal/Magento/Framework/Filesystem/Driver/File.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,13 @@ public function fileUnlock($resource)
843843
*/
844844
public function getAbsolutePath($basePath, $path, $scheme = null)
845845
{
846+
// check if the path given is already an absolute path containing the
847+
// basepath. so if the basepath starts at position 0 in the path, we
848+
// must not concatinate them again because path is already absolute.
849+
if (0 === strpos($path, $basePath)) {
850+
return $this->getScheme($scheme) . $path;
851+
}
852+
846853
return $this->getScheme($scheme) . $basePath . ltrim($this->fixSeparator($path), '/');
847854
}
848855

lib/internal/Magento/Framework/Filesystem/Driver/Http.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,13 @@ public function fileReadLine($resource, $length, $ending = null)
213213
*/
214214
public function getAbsolutePath($basePath, $path, $scheme = null)
215215
{
216+
// check if the path given is already an absolute path containing the
217+
// basepath. so if the basepath starts at position 0 in the path, we
218+
// must not concatinate them again because path is already absolute.
219+
if (0 === strpos($path, $basePath)) {
220+
return $this->getScheme() . $path;
221+
}
222+
216223
return $this->getScheme() . $basePath . $path;
217224
}
218225

lib/internal/Magento/Framework/Filesystem/Test/Unit/Driver/FileTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public function testGetAbsolutePath($basePath, $path, $expected)
3030
$file = new File();
3131
$this->assertEquals($expected, $file->getAbsolutePath($basePath, $path));
3232
}
33-
33+
3434
public function dataProviderForTestGetAbsolutePath()
3535
{
3636
return [
3737
['/root/path/', 'sub', '/root/path/sub'],
3838
['/root/path/', '/sub', '/root/path/sub'],
3939
['/root/path/', '../sub', '/root/path/../sub'],
40-
['/root/path/', '/root/path/sub', '/root/path/root/path/sub'],
40+
['/root/path/', '/root/path/sub', '/root/path/sub'],
4141
];
4242
}
4343

0 commit comments

Comments
 (0)