Skip to content

Commit

Permalink
MAGETWO-67590: Fix filesystem permission issues #5372
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksii Korshenko authored Apr 21, 2017
2 parents e9e96c3 + 621e245 commit eaaa397
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/internal/Magento/Framework/Filesystem/Driver/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,13 @@ public function fileUnlock($resource)
*/
public function getAbsolutePath($basePath, $path, $scheme = null)
{
// check if the path given is already an absolute path containing the
// basepath. so if the basepath starts at position 0 in the path, we
// must not concatinate them again because path is already absolute.
if (0 === strpos($path, $basePath)) {
return $this->getScheme($scheme) . $path;
}

return $this->getScheme($scheme) . $basePath . ltrim($this->fixSeparator($path), '/');
}

Expand Down
7 changes: 7 additions & 0 deletions lib/internal/Magento/Framework/Filesystem/Driver/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ public function fileReadLine($resource, $length, $ending = null)
*/
public function getAbsolutePath($basePath, $path, $scheme = null)
{
// check if the path given is already an absolute path containing the
// basepath. so if the basepath starts at position 0 in the path, we
// must not concatinate them again because path is already absolute.
if (0 === strpos($path, $basePath)) {
return $this->getScheme() . $path;
}

return $this->getScheme() . $basePath . $path;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public function testGetAbsolutePath($basePath, $path, $expected)
$file = new File();
$this->assertEquals($expected, $file->getAbsolutePath($basePath, $path));
}

public function dataProviderForTestGetAbsolutePath()
{
return [
['/root/path/', 'sub', '/root/path/sub'],
['/root/path/', '/sub', '/root/path/sub'],
['/root/path/', '../sub', '/root/path/../sub'],
['/root/path/', '/root/path/sub', '/root/path/root/path/sub'],
['/root/path/', '/root/path/sub', '/root/path/sub'],
];
}

Expand Down

0 comments on commit eaaa397

Please sign in to comment.