Merge pull request #35949 from nextcloud/backport/33941/stable24

[stable24] Only normalize data in public shares and not crud
This commit is contained in:
Vincent Petry 2023-01-04 10:26:25 +01:00 committed by GitHub
commit 02a9a77001
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View file

@ -1173,7 +1173,9 @@ class ShareAPIController extends OCSController {
}
// 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) {

View file

@ -2946,7 +2946,7 @@ class ShareAPIControllerTest extends TestCase {
// 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 @@ class ShareAPIControllerTest extends TestCase {
$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 @@ class ShareAPIControllerTest extends TestCase {
->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());

View file

@ -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