Skip to content

Commit

Permalink
Only normalize data in public shares and not crud
Browse files Browse the repository at this point in the history
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
  • Loading branch information
CarlSchwan committed Sep 8, 2022
1 parent f496e47 commit 7f1bfc0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3037,7 +3037,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
[
Expand Down Expand Up @@ -3538,7 +3538,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 &&
Expand Down Expand Up @@ -3567,7 +3567,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());
Expand Down

0 comments on commit 7f1bfc0

Please sign in to comment.