Skip to content

Commit f4b4cb5

Browse files
authored
Revert "feat(group): Sanitize group names and ids on creation"
1 parent 6ba4ca3 commit f4b4cb5

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

lib/private/Group/Database.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ private function fixDI() {
6767
public function createGroup(string $name): ?string {
6868
$this->fixDI();
6969

70-
$name = $this->sanitizeGroupName($name);
7170
$gid = $this->computeGid($name);
7271
try {
7372
// Add group
@@ -587,21 +586,12 @@ public function getBackendName(): string {
587586
return 'Database';
588587
}
589588

590-
/**
591-
* Merge any white spaces to a single space in group name, then trim it.
592-
*/
593-
private function sanitizeGroupName(string $displayName): string {
594-
$cleanedDisplayName = preg_replace('/\s+/', ' ', $displayName);
595-
return trim($cleanedDisplayName);
596-
}
597-
598589
/**
599590
* Compute group ID from display name (GIDs are limited to 64 characters in database)
600591
*/
601592
private function computeGid(string $displayName): string {
602-
$displayNameWithoutWhitespace = preg_replace('/\s+/', '_', $displayName);
603-
return mb_strlen($displayNameWithoutWhitespace) > 64
604-
? hash('sha256', $displayNameWithoutWhitespace)
605-
: $displayNameWithoutWhitespace;
593+
return mb_strlen($displayName) > 64
594+
? hash('sha256', $displayName)
595+
: $displayName;
606596
}
607597
}

tests/lib/Group/DatabaseTest.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,4 @@ public function testAddLongGroupName(): void {
5757
$group = $this->backend->getGroupDetails($gidCreated);
5858
$this->assertEquals(['displayName' => $groupName], $group);
5959
}
60-
61-
public function testWhiteSpaceInGroupName(): void {
62-
$randomId = $this->getUniqueID('test_', 10);
63-
$groupName = " group name with weird spaces \n" . $randomId;
64-
$expectedGroupName = 'group name with weird spaces ' . $randomId;
65-
$expectedGroupId = 'group_name_with_weird_spaces_' . $randomId;
66-
67-
$gidCreated = $this->backend->createGroup($groupName);
68-
$this->assertEquals($expectedGroupId, $gidCreated);
69-
70-
$group = $this->backend->getGroupDetails($gidCreated);
71-
$this->assertEquals(['displayName' => $expectedGroupName], $group);
72-
}
7360
}

0 commit comments

Comments
 (0)