Remove unnecessary group name validation

This commit is contained in:
Tom Needham 2015-12-04 13:21:24 +00:00 committed by Morris Jobke
parent a0345b9465
commit 673a8a1e4a
2 changed files with 22 additions and 1 deletions

View File

@ -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');
}

View File

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