diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-11-05 13:42:52 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-11-13 11:25:30 +0100 |
commit | c52dd9f658f253ba039bc4a44eb69080ff5e2f28 (patch) | |
tree | df0c73e21076a0923e2a6fd824fab5e18ec628ee | |
parent | fd1967f1eeadecae7f753c7c49a5e92245818568 (diff) |
Filter returned shares on accessibility
Fixes #1272
The same code as in server. It makes sure we do not return shares that
are in in the trash as this will result in mounting issues.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r-- | lib/Share/RoomShareProvider.php | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/Share/RoomShareProvider.php b/lib/Share/RoomShareProvider.php index 7b5f7678c..0659c5d47 100644 --- a/lib/Share/RoomShareProvider.php +++ b/lib/Share/RoomShareProvider.php @@ -745,10 +745,16 @@ class RoomShareProvider implements IShareProvider { } $qb = $this->dbConnection->getQueryBuilder(); - $qb->select('*') - ->from('share') + $qb->select('s.*', + 'f.fileid', 'f.path', 'f.permissions AS f_permissions', 'f.storage', 'f.path_hash', + 'f.parent AS f_parent', 'f.name', 'f.mimetype', 'f.mimepart', 'f.size', 'f.mtime', 'f.storage_mtime', + 'f.encrypted', 'f.unencrypted_size', 'f.etag', 'f.checksum' + ) + ->selectAlias('st.id', 'storage_string_id') + ->from('share', 's') ->orderBy('id') - ->setFirstResult(0); + ->leftJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid')) + ->leftJoin('f', 'storages', 'st', $qb->expr()->eq('f.storage', 'st.numeric_id')); if ($limit !== -1) { $qb->setMaxResults($limit); @@ -773,6 +779,10 @@ class RoomShareProvider implements IShareProvider { $cursor = $qb->execute(); while ($data = $cursor->fetch()) { + if (!$this->isAccessibleResult($data)) { + continue; + } + if ($offset > 0) { $offset--; continue; @@ -788,6 +798,22 @@ class RoomShareProvider implements IShareProvider { return $shares; } + private function isAccessibleResult($data) { + // exclude shares leading to deleted file entries + if ($data['fileid'] === null) { + return false; + } + + // exclude shares leading to trashbin on home storages + $pathSections = explode('/', $data['path'], 2); + // FIXME: would not detect rare md5'd home storage case properly + if ($pathSections[0] !== 'files' + && in_array(explode(':', $data['storage_string_id'], 2)[0], array('home', 'object'))) { + return false; + } + return true; + } + /** * Get a share by token * |