summary refs log tree commit diff
path: root/synapse/groups
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2017-10-20 23:37:22 +0100
committerRichard van der Hoff <richard@matrix.org>2017-10-20 23:37:22 +0100
commit58fbbe0f1db78d9dc91a319874dc8409e77cbf4c (patch)
tree218d3fc495b5aac352988b097a0ad1b65528d254 /synapse/groups
parentMerge pull request #2559 from matrix-org/erikj/group_id_validation (diff)
downloadsynapse-58fbbe0f1db78d9dc91a319874dc8409e77cbf4c.tar.xz
Disallow capital letters in userids
Factor out a common function for checking user ids and group ids, which forbids
capitals.
Diffstat (limited to 'synapse/groups')
-rw-r--r--synapse/groups/groups_server.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/synapse/groups/groups_server.py b/synapse/groups/groups_server.py
index fc4edb7f04..c359bfa72b 100644
--- a/synapse/groups/groups_server.py
+++ b/synapse/groups/groups_server.py
@@ -13,14 +13,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from twisted.internet import defer
+import logging
 
+from synapse import types
 from synapse.api.errors import SynapseError
-from synapse.types import UserID, get_domain_from_id, RoomID, GroupID
-
-
-import logging
-import urllib
+from synapse.types import GroupID, RoomID, UserID, get_domain_from_id
+from twisted.internet import defer
 
 logger = logging.getLogger(__name__)
 
@@ -793,10 +791,7 @@ def _validate_group_id(group_id):
     """
     localpart = GroupID.from_string(group_id).localpart
 
-    if localpart.lower() != localpart:
-        raise SynapseError(400, "Group ID must be lower case")
-
-    if urllib.quote(localpart.encode('utf-8')) != localpart:
+    if types.contains_invalid_mxid_characters(localpart):
         raise SynapseError(
             400,
             "Group ID can only contain characters a-z, 0-9, or '_-./'",