-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add domain validation when creating room with list of invitees #6121
Conversation
…regression test. Should resolve matrix-org#40
…regression test. Should resolve matrix-org#40 Signed-off-by: Werner Kroneman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm otherwise
synapse/handlers/room.py
Outdated
@@ -554,7 +555,9 @@ def create_room(self, requester, config, ratelimit=True, creator_join_profile=No | |||
invite_list = config.get("invite", []) | |||
for i in invite_list: | |||
try: | |||
UserID.from_string(i) | |||
uid = UserID.from_string(i) | |||
# TODO Maybe attempt idna encoding/decoding as well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@richvdh Do you have any thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do have thoughts on it. https://matrix.org/docs/spec/appendices#server-name is clear that server_names (and hence mxids) may contain only ascii: it's up to the client to do idna-encoding/decoding on them if it so desires.
Please can we get rid of the todo!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# TODO Maybe attempt idna encoding/decoding as well? |
tests/rest/client/v1/test_rooms.py
Outdated
@@ -485,6 +485,14 @@ def test_post_room_invalid_content(self): | |||
self.assertEquals(400, channel.code) | |||
|
|||
|
|||
def test_post_room_invitees_invalid_mxid(self): | |||
# POST with invalid invitee, see https://github.com/matrix-org/synapse/issues/4088 | |||
# Note the trailing slash in the MXID here! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Note the trailing slash in the MXID here! | |
# Note the trailing space in the MXID here! |
Pull Request Checklist
This results in a 400 bad request status instead of 500 internal server error in the case described in #4088 (trailing whitespace).
Also adds a regression test for this issue.
Question: An original (abandoned) attempt to fix this issue (see https://github.com/matrix-org/synapse/pull/4351/files) also does some trial encoding/decoding with IDNA. Should we try to do that as well? (See the TODO entry)