summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-03-01 08:17:56 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-03-01 08:17:56 +0100
commitf3050b3adbeb187f72bd319bbde1175cce12392e (patch)
tree0451018f948cde0b45d16961b83b5d3634c26df6 /apps
parenta06f59c58032f133aa58f645c944bcd63c5a0937 (diff)
parent8924b0a0dca9b23c77d0d5ae915c58705d2dfcaf (diff)
downloadnextcloud-server-f3050b3adbeb187f72bd319bbde1175cce12392e.tar.gz
nextcloud-server-f3050b3adbeb187f72bd319bbde1175cce12392e.zip
Merge pull request #22740 from owncloud/fix_resare_updates
Check correct permissions when resharing
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/api/share20ocs.php16
-rw-r--r--apps/files_sharing/tests/api/share20ocstest.php4
2 files changed, 20 insertions, 0 deletions
diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php
index 588538fbb6c..f5834fb2831 100644
--- a/apps/files_sharing/api/share20ocs.php
+++ b/apps/files_sharing/api/share20ocs.php
@@ -594,6 +594,22 @@ class Share20OCS {
}
}
+ if ($permissions !== null) {
+ /* Check if this is an incomming share */
+ $incomingShares = $this->shareManager->getSharedWith($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $share->getNode(), -1, 0);
+ $incomingShares = array_merge($incomingShares, $this->shareManager->getSharedWith($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $share->getNode(), -1, 0));
+
+ if (!empty($incomingShares)) {
+ $maxPermissions = 0;
+ foreach ($incomingShares as $incomingShare) {
+ $maxPermissions |= $incomingShare->getPermissions();
+ }
+
+ if ($share->getPermissions() & ~$maxPermissions) {
+ return new \OC_OCS_Result(null, 404, 'Cannot increase permissions');
+ }
+ }
+ }
try {
diff --git a/apps/files_sharing/tests/api/share20ocstest.php b/apps/files_sharing/tests/api/share20ocstest.php
index 057df20a5a4..81db3b96333 100644
--- a/apps/files_sharing/tests/api/share20ocstest.php
+++ b/apps/files_sharing/tests/api/share20ocstest.php
@@ -1433,6 +1433,8 @@ class Share20OCSTest extends \Test\TestCase {
})
)->will($this->returnArgument(0));
+ $this->shareManager->method('getSharedWith')->willReturn([]);
+
$expected = new \OC_OCS_Result(null);
$result = $ocs->updateShare(42);
@@ -1498,6 +1500,8 @@ class Share20OCSTest extends \Test\TestCase {
})
)->will($this->returnArgument(0));
+ $this->shareManager->method('getSharedWith')->willReturn([]);
+
$expected = new \OC_OCS_Result(null);
$result = $ocs->updateShare(42);