diff --git a/docs/conversation.md b/docs/conversation.md index 4b18e59d9bf..deb53246f69 100644 --- a/docs/conversation.md +++ b/docs/conversation.md @@ -100,7 +100,7 @@ | `roomType` | int | See [constants list](constants.md#conversation-types) | | `invite` | string | user id (`roomType = 1`), group id (`roomType = 2` - optional), circle id (`roomType = 2`, `source = 'circles'`], only available with `circles-support` capability)) | | `source` | string | The source for the invite, only supported on `roomType = 2` for `groups` and `circles` (only available with `circles-support` capability) | -| `roomName` | string | conversation name (Not available for `roomType = 1`) | +| `roomName` | string | Conversation name up to 255 characters (Not available for `roomType = 1`) | * Response: - Status code: @@ -156,9 +156,9 @@ * Endpoint: `/room/{token}` * Data: -| field | type | Description | -|------------|--------|--------------------------------------------------| -| `roomName` | string | New name for the conversation (1-200 characters) | +| field | type | Description | +|------------|--------|------------------------------------------------------| +| `roomName` | string | New name for the conversation (up to 255 characters) | * Response: - Status code: diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 79b06b63231..02701541f76 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -869,7 +869,7 @@ public function renameRoom(string $roomName): DataResponse { $roomName = trim($roomName); - if ($roomName === '' || strlen($roomName) > 200) { + if ($roomName === '' || mb_strlen($roomName) > 255) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } diff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php index d083bfb5f29..644595784fa 100644 --- a/lib/Service/RoomService.php +++ b/lib/Service/RoomService.php @@ -132,7 +132,7 @@ public function createOneToOneConversation(IUser $actor, IUser $targetUser): Roo */ public function createConversation(int $type, string $name, ?IUser $owner = null, string $objectType = '', string $objectId = ''): Room { $name = trim($name); - if ($name === '' || isset($name[255])) { + if ($name === '' || mb_strlen($name) > 255) { throw new InvalidArgumentException('name'); } diff --git a/tests/integration/features/chat/public.feature b/tests/integration/features/chat/public.feature index 7f3391ec96a..0c3a1ef6cd7 100644 --- a/tests/integration/features/chat/public.feature +++ b/tests/integration/features/chat/public.feature @@ -96,3 +96,18 @@ Feature: chat/public | public room | guests | guest | | Message 3 | [] | | public room | users | participant2 | participant2-displayname | Message 2 | [] | | public room | users | participant1 | participant1-displayname | Message 1 | [] | + + + Scenario: Create room with big name and rename + # 260 chars + When user "participant1" creates room "public room" with 400 (v4) + | roomType | 3 | + | roomName | A name with 260 chars 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678 | + # 255 chars + And user "participant1" creates room "public room" (v4) + | roomType | 3 | + | roomName | A name with 255 chars 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123 | + # 260 chars + And user "participant1" renames room "public room" to "A name with 260 chars 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678" with 400 (v4) + # 255 chars + And user "participant1" renames room "public room" to "Another name with 255 chars 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567" with 200 (v4) diff --git a/tests/php/Service/RoomServiceTest.php b/tests/php/Service/RoomServiceTest.php index 4ee95a62258..4f862626344 100644 --- a/tests/php/Service/RoomServiceTest.php +++ b/tests/php/Service/RoomServiceTest.php @@ -192,6 +192,11 @@ public function dataCreateConversationInvalidNames(): array { [''], [' '], [str_repeat('a', 256)], + // Isn't a multibyte emoji + [str_repeat('😃', 256)], + // This is a multibyte emoji and need 2 chars in database + // 256 / 2 = 128 + [str_repeat('‍💻', 128)], ]; }