From 1027d62a8226ea2638856af121267a813ec3260a Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Wed, 7 Sep 2022 13:51:38 +0200 Subject: [PATCH] Only normalize data in public shares and not crud Signed-off-by: Carl Schwan --- apps/files_sharing/lib/Controller/ShareAPIController.php | 4 +++- .../tests/Controller/ShareAPIControllerTest.php | 6 +++--- build/integration/sharing_features/sharing-v1.feature | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 0bd7770880580..d37424e0ecb2f 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -1173,7 +1173,9 @@ public function updateShare( } // normalize to correct public upload permissions - $newPermissions = Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE; + if ($publicUpload === 'true') { + $newPermissions = Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE; + } } if ($newPermissions !== null) { diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index b71f603e83be1..009b14a7a245e 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -2946,7 +2946,7 @@ public function publicUploadParamsProvider() { // legacy had no delete [ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE, - null, null, 'password' + 'true', null, 'password' ], // correct [ @@ -3439,7 +3439,7 @@ public function testUpdateLinkSharePermissions() { $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); $this->shareManager->expects($this->once())->method('updateShare')->with( - $this->callback(function (\OCP\Share\IShare $share) use ($date) { + $this->callback(function (\OCP\Share\IShare $share) use ($date): bool { return $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) && $share->getPassword() === 'password' && $share->getSendPasswordByTalk() === true && @@ -3467,7 +3467,7 @@ public function testUpdateLinkSharePermissions() { ->willReturn(42); $expected = new DataResponse([]); - $result = $ocs->updateShare(42, 7, null, null, null, null, null, null, null); + $result = $ocs->updateShare(42, 7, null, null, 'true', null, null, null, null); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); diff --git a/build/integration/sharing_features/sharing-v1.feature b/build/integration/sharing_features/sharing-v1.feature index fbcbb50b7ded7..ca030bd3a31fa 100644 --- a/build/integration/sharing_features/sharing-v1.feature +++ b/build/integration/sharing_features/sharing-v1.feature @@ -269,6 +269,7 @@ Feature: sharing | shareType | 3 | And Updating last share with | permissions | 7 | + | publicUpload | true | And the OCS status code should be "100" And the HTTP status code should be "200" And Getting info of last share