aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/api
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-02-16 16:04:17 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-02-17 13:55:39 +0100
commit2aa0b885f622af21f80f6a36e744d4ecf74fdfff (patch)
tree713a92ff9dcc6b57dfcefbc5ac1bde779342e5d5 /apps/files_sharing/api
parent7b0f83b616246c5274b551ab46b923b0989c464e (diff)
downloadnextcloud-server-2aa0b885f622af21f80f6a36e744d4ecf74fdfff.tar.gz
nextcloud-server-2aa0b885f622af21f80f6a36e744d4ecf74fdfff.zip
OCS Share API should not return invalid shares
Since we have lazy shares it can happen that a share is actually invalid. See https://github.com/owncloud/core/issues/20908 This add checks for the get methods to handle the NotFound exception.
Diffstat (limited to 'apps/files_sharing/api')
-rw-r--r--apps/files_sharing/api/share20ocs.php32
1 files changed, 25 insertions, 7 deletions
diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php
index 688ed5b3ee5..309e1159fff 100644
--- a/apps/files_sharing/api/share20ocs.php
+++ b/apps/files_sharing/api/share20ocs.php
@@ -20,6 +20,7 @@
*/
namespace OCA\Files_Sharing\API;
+use OCP\Files\NotFoundException;
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\IRequest;
@@ -83,6 +84,7 @@ class Share20OCS {
*
* @param \OCP\Share\IShare $share
* @return array
+ * @throws NotFoundException In case the node can't be resolved.
*/
protected function formatShare(\OCP\Share\IShare $share) {
$sharedBy = $this->userManager->get($share->getSharedBy());
@@ -177,11 +179,15 @@ class Share20OCS {
}
if ($this->canAccessShare($share)) {
- $share = $this->formatShare($share);
- return new \OC_OCS_Result([$share]);
- } else {
- return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
+ try {
+ $share = $this->formatShare($share);
+ return new \OC_OCS_Result([$share]);
+ } catch (NotFoundException $e) {
+ //Fall trough
+ }
}
+
+ return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
}
/**
@@ -368,7 +374,11 @@ class Share20OCS {
$formatted = [];
foreach ($shares as $share) {
if ($this->canAccessShare($share)) {
- $formatted[] = $this->formatShare($share);
+ try {
+ $formatted[] = $this->formatShare($share);
+ } catch (NotFoundException $e) {
+ // Ignore this share
+ }
}
}
@@ -398,7 +408,11 @@ class Share20OCS {
$formatted = [];
foreach ($shares as $share) {
- $formatted[] = $this->formatShare($share);
+ try {
+ $formatted[] = $this->formatShare($share);
+ } catch (NotFoundException $e) {
+ //Ignore this share
+ }
}
return new \OC_OCS_Result($formatted);
@@ -458,7 +472,11 @@ class Share20OCS {
$formatted = [];
foreach ($shares as $share) {
- $formatted[] = $this->formatShare($share);
+ try {
+ $formatted[] = $this->formatShare($share);
+ } catch (NotFoundException $e) {
+ //Ignore share
+ }
}
return new \OC_OCS_Result($formatted);