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

Add domain validation when creating room with list of invitees #6121

Merged
merged 4 commits into from
Oct 10, 2019

Conversation

werner291
Copy link
Contributor

@werner291 werner291 commented Sep 27, 2019

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file
  • Pull request includes a sign off

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)

Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm otherwise

@@ -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?
Copy link
Member

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?

Copy link
Member

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!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# TODO Maybe attempt idna encoding/decoding as well?

@@ -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!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Note the trailing slash in the MXID here!
# Note the trailing space in the MXID here!

@richvdh richvdh changed the title Added domain validation upon creating room with list of invitees Add domain validation upon creating room with list of invitees Sep 30, 2019
@richvdh richvdh changed the title Add domain validation upon creating room with list of invitees Add domain validation when creating room with list of invitees Sep 30, 2019
@richvdh richvdh removed their request for review September 30, 2019 16:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants