Browse Source

Do not use $_GET

The appframework is more than capable of handling this properly.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
tags/v18.0.0RC2
Roeland Jago Douma 4 years ago
parent
commit
1672ff3bef
No account linked to committer's email address

+ 3
- 4
apps/files_sharing/lib/Controller/ShareesAPIController.php View File

@@ -198,13 +198,12 @@ class ShareesAPIController extends OCSController {
$shareTypes[] = Share::SHARE_TYPE_CIRCLE;
}

if (isset($_GET['shareType']) && is_array($_GET['shareType'])) {
$shareTypes = array_intersect($shareTypes, $_GET['shareType']);
sort($shareTypes);
if ($shareType !== null && is_array($shareType)) {
$shareTypes = array_intersect($shareTypes, $shareType);
} else if (is_numeric($shareType)) {
$shareTypes = array_intersect($shareTypes, [(int) $shareType]);
sort($shareTypes);
}
sort($shareTypes);

$this->shareWithGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
$this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';

+ 5
- 2
apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php View File

@@ -271,9 +271,12 @@ class ShareesAPIControllerTest extends TestCase {
->setMethods(['isRemoteSharingAllowed', 'shareProviderExists', 'isRemoteGroupSharingAllowed'])
->getMock();

$expectedShareTypes = $shareTypes;
sort($expectedShareTypes);

$this->collaboratorSearch->expects($this->once())
->method('search')
->with($search, $shareTypes, $this->anything(), $perPage, $perPage * ($page -1))
->with($search, $expectedShareTypes, $this->anything(), $perPage, $perPage * ($page -1))
->willReturn([[], false]);

$sharees->expects($this->any())
@@ -398,7 +401,7 @@ class ShareesAPIControllerTest extends TestCase {
$this->assertSame($expected, $this->invokePrivate($this->sharees, 'isRemoteSharingAllowed', [$itemType]));
}

public function testSearchNoItemType() {
$this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
$this->expectExceptionMessage('Missing itemType');

Loading…
Cancel
Save