From 673a8a1e4a15edb3e6199432fc7e53714a651bb3 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Fri, 4 Dec 2015 13:21:24 +0000 Subject: [PATCH] Remove unnecessary group name validation --- apps/provisioning_api/lib/groups.php | 2 +- apps/provisioning_api/tests/groupstest.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/provisioning_api/lib/groups.php b/apps/provisioning_api/lib/groups.php index 7a6e615078..633e35357d 100644 --- a/apps/provisioning_api/lib/groups.php +++ b/apps/provisioning_api/lib/groups.php @@ -130,7 +130,7 @@ class Groups{ public function addGroup($parameters) { // Validate name $groupId = $this->request->getParam('groupid', ''); - if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $groupId ) || empty($groupId)){ + if(empty($groupId)){ \OCP\Util::writeLog('provisioning_api', 'Attempt made to create group using invalid characters.', \OCP\Util::ERROR); return new OC_OCS_Result(null, 101, 'Invalid group name'); } diff --git a/apps/provisioning_api/tests/groupstest.php b/apps/provisioning_api/tests/groupstest.php index f4f3b19494..84950d923e 100644 --- a/apps/provisioning_api/tests/groupstest.php +++ b/apps/provisioning_api/tests/groupstest.php @@ -373,6 +373,27 @@ class GroupsTest extends \Test\TestCase { $this->assertTrue($result->succeeded()); } + public function testAddGroupWithSpecialChar() { + $this->request + ->method('getParam') + ->with('groupid') + ->willReturn('Iñtërnâtiônàlizætiøn'); + + $this->groupManager + ->method('groupExists') + ->with('NewGroup') + ->willReturn(false); + + $this->groupManager + ->expects($this->once()) + ->method('createGroup') + ->with('Iñtërnâtiônàlizætiøn'); + + $result = $this->api->addGroup([]); + $this->assertInstanceOf('OC_OCS_Result', $result); + $this->assertTrue($result->succeeded()); + } + public function testDeleteGroupNonExisting() { $result = $this->api->deleteGroup([ 'groupid' => 'NonExistingGroup'