Skip to content

Commit 03cdff0

Browse files
authored
Merge pull request #18674 from nextcloud/enh/no_global_GET
Do not use $_GET
2 parents 32f79c9 + 1672ff3 commit 03cdff0

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

apps/files_sharing/lib/Controller/ShareesAPIController.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,12 @@ public function search(string $search = '', string $itemType = null, int $page =
198198
$shareTypes[] = Share::SHARE_TYPE_CIRCLE;
199199
}
200200

201-
if (isset($_GET['shareType']) && is_array($_GET['shareType'])) {
202-
$shareTypes = array_intersect($shareTypes, $_GET['shareType']);
203-
sort($shareTypes);
201+
if ($shareType !== null && is_array($shareType)) {
202+
$shareTypes = array_intersect($shareTypes, $shareType);
204203
} else if (is_numeric($shareType)) {
205204
$shareTypes = array_intersect($shareTypes, [(int) $shareType]);
206-
sort($shareTypes);
207205
}
206+
sort($shareTypes);
208207

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

apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,12 @@ public function testSearch($getData, $apiSetting, $enumSetting, $remoteSharingEn
271271
->setMethods(['isRemoteSharingAllowed', 'shareProviderExists', 'isRemoteGroupSharingAllowed'])
272272
->getMock();
273273

274+
$expectedShareTypes = $shareTypes;
275+
sort($expectedShareTypes);
276+
274277
$this->collaboratorSearch->expects($this->once())
275278
->method('search')
276-
->with($search, $shareTypes, $this->anything(), $perPage, $perPage * ($page -1))
279+
->with($search, $expectedShareTypes, $this->anything(), $perPage, $perPage * ($page -1))
277280
->willReturn([[], false]);
278281

279282
$sharees->expects($this->any())
@@ -398,7 +401,7 @@ public function testIsRemoteSharingAllowed($itemType, $expected) {
398401
$this->assertSame($expected, $this->invokePrivate($this->sharees, 'isRemoteSharingAllowed', [$itemType]));
399402
}
400403

401-
404+
402405
public function testSearchNoItemType() {
403406
$this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
404407
$this->expectExceptionMessage('Missing itemType');

0 commit comments

Comments
 (0)