This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 1+ Give a meaningful error message when a client tries to create a room with an invalid alias localpart.
Original file line number Diff line number Diff line change @@ -71,6 +71,9 @@ async def _create_association(
7171 if wchar in room_alias .localpart :
7272 raise SynapseError (400 , "Invalid characters in room alias" )
7373
74+ if ":" in room_alias .localpart :
75+ raise SynapseError (400 , "Invalid character in room alias localpart: ':'." )
76+
7477 if not self .hs .is_mine (room_alias ):
7578 raise SynapseError (400 , "Room alias must be local" )
7679 # TODO(erikj): Change this.
Original file line number Diff line number Diff line change @@ -751,6 +751,21 @@ async def create_room(
751751 if wchar in config ["room_alias_name" ]:
752752 raise SynapseError (400 , "Invalid characters in room alias" )
753753
754+ if ":" in config ["room_alias_name" ]:
755+ # Prevent someone from trying to pass in a full alias here.
756+ # Note that it's permissible for a room alias to have multiple
757+ # hash symbols at the start (notably bridged over from IRC, too),
758+ # but the first colon in the alias is defined to separate the local
759+ # part from the server name.
760+ # (remember server names can contain port numbers, also separated
761+ # by a colon. But under no circumstances should the local part be
762+ # allowed to contain a colon!)
763+ raise SynapseError (
764+ 400 ,
765+ "':' is not permitted in the room alias name. "
766+ "Please note this expects a local part — 'wombat', not '#wombat:example.com'." ,
767+ )
768+
754769 room_alias = RoomAlias (config ["room_alias_name" ], self .hs .hostname )
755770 mapping = await self .store .get_association_from_room_alias (room_alias )
756771
You can’t perform that action at this time.
0 commit comments