]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do not use $_GET 18674/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Sun, 5 Jan 2020 14:51:16 +0000 (15:51 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Sun, 5 Jan 2020 19:13:11 +0000 (20:13 +0100)
The appframework is more than capable of handling this properly.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
apps/files_sharing/lib/Controller/ShareesAPIController.php
apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php

index d556ab76f6537bba00022c3e667198f0d7036556..61678e67c174c7bd633b54d93b99e2ba61f382d0 100644 (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';
index 8c0c5b1e41c57dffdda572395be7005218b0880a..1fb14ad9b8f1b2075b569fbea788d09d599c900d 100644 (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');