From 4abaa93cf03b2c020bacb497274d8d80fce20161 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 19 Oct 2017 16:28:02 +0100 Subject: [PATCH] Add clientside error for non-alphanumeric group ID --- src/components/views/dialogs/CreateGroupDialog.js | 6 +++++- src/i18n/strings/en_EN.json | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/views/dialogs/CreateGroupDialog.js b/src/components/views/dialogs/CreateGroupDialog.js index ccb051d3e1..70d16da634 100644 --- a/src/components/views/dialogs/CreateGroupDialog.js +++ b/src/components/views/dialogs/CreateGroupDialog.js @@ -66,8 +66,12 @@ export default React.createClass({ {domain: MatrixClientPeg.get().getDomain()}, ); } else { + const groupId = parsedGroupId[0]; const domain = parsedGroupId[1]; - if (domain !== MatrixClientPeg.get().getDomain()) { + + if (!/^[a-zA-Z0-9]*$/.test(groupId)) { + error = _t("Community IDs may only contain alphanumeric characters"); + } else if (domain !== MatrixClientPeg.get().getDomain()) { error = _t( "It is currently only possible to create communities on your own home server: "+ "use a community ID ending with %(domain)s", diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 9fbf16e5da..3b48ebefaa 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -583,6 +583,7 @@ "Are you sure you wish to remove (delete) this event? Note that if you delete a room name or topic change, it could undo the change.": "Are you sure you wish to remove (delete) this event? Note that if you delete a room name or topic change, it could undo the change.", "%(actionVerb)s this person?": "%(actionVerb)s this person?", "Community IDs must be of the form +localpart:%(domain)s": "Community IDs must be of the form +localpart:%(domain)s", + "Community IDs may only contain alphanumeric characters": "Community IDs may only contain alphanumeric characters", "It is currently only possible to create communities on your own home server: use a community ID ending with %(domain)s": "It is currently only possible to create communities on your own home server: use a community ID ending with %(domain)s", "Room creation failed": "Room creation failed", "Create Community": "Create Community",