mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-30 17:58:39 +01:00
Fix sharing of of a file inside a symlinked directory failed.
This commit is contained in:
parent
e3ede597dc
commit
a3c6eba952
@ -316,11 +316,29 @@ class Sharing extends \EGroupware\Api\Sharing
|
||||
$path = 'vfs://default'.($path[0] == '/' ? '' : '/').$path;
|
||||
}
|
||||
|
||||
// We don't allow sharing links, share target instead
|
||||
// We don't allow sharing paths that contain links, resolve to target instead
|
||||
if(($target = Vfs::readlink($path)))
|
||||
{
|
||||
$path = $target;
|
||||
}
|
||||
$check = $path;
|
||||
do
|
||||
{
|
||||
if(($delinked = Vfs::readlink($check)))
|
||||
{
|
||||
if($delinked[strlen($delinked)-1] == '/') $check .='/';
|
||||
$path = str_replace($check, $delinked, $path);
|
||||
if(parse_url($path, PHP_URL_SCHEME) !== 'vfs')
|
||||
{
|
||||
$path = 'vfs://default'.($path[0] == '/' ? '' : '/').$path;
|
||||
}
|
||||
$check = $path;
|
||||
}
|
||||
else
|
||||
{
|
||||
$check = Vfs::dirname($check);
|
||||
}
|
||||
} while ($check && $check != '/');
|
||||
|
||||
if (($exists = ($stat = Vfs::stat($path)) && Vfs::check_access($path, Vfs::READABLE, $stat)))
|
||||
{
|
||||
|
@ -262,6 +262,28 @@ class SharingTest extends SharingBase
|
||||
$this->assertEquals($file, $created_share['share_path']);
|
||||
}
|
||||
|
||||
public function testShareFileInsideSymlinkDirectory()
|
||||
{
|
||||
$target = Vfs::get_home_dir();
|
||||
|
||||
$this->files = $this->addFiles($target);
|
||||
$target_file = $target.'/sub_dir/'.'subdir_test_file.txt';
|
||||
|
||||
// Make symlink
|
||||
$this->files[] = $symlink = $target.'/symlinked_dir/';
|
||||
$file = $symlink.'subdir_test_file.txt';
|
||||
if(Vfs::file_exists($symlink)) Vfs::remove($symlink);
|
||||
$this->assertTrue(
|
||||
Vfs::symlink($target.'/sub_dir/', $symlink),
|
||||
"Unable to create symlink $symlink => $target/sub_dir/"
|
||||
);
|
||||
|
||||
// Create share
|
||||
$this->shares[] = $created_share = Sharing::create('', $file, Sharing::READONLY, '', '');
|
||||
|
||||
$this->assertEquals(Vfs::PREFIX . $target_file, $created_share['share_path']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a share of a single file gives the file (uses WebDAV)
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user