Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filesystem permission issues #5372

Merged
merged 2 commits into from
Apr 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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