Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Ensure a group ID is valid before trying to get rooms for it. #8129

Merged
merged 1 commit into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8129.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Return a proper error code when the rooms of an invalid group are requested.
4 changes: 4 additions & 0 deletions synapse/rest/client/v2_alpha/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import logging

from synapse.api.errors import SynapseError
from synapse.http.servlet import RestServlet, parse_json_object_from_request
from synapse.types import GroupID

Expand Down Expand Up @@ -325,6 +326,9 @@ async def on_GET(self, request, group_id):
requester = await self.auth.get_user_by_req(request, allow_guest=True)
requester_user_id = requester.user.to_string()

if not GroupID.is_valid(group_id):
raise SynapseError(400, "%s was not legal group ID" % (group_id,))

result = await self.groups_handler.get_rooms_in_group(
group_id, requester_user_id
)
Expand Down