From 8c82f1bbfff4f0854fe8b7309a62308551b0abfa Mon Sep 17 00:00:00 2001 From: A Arroyo Date: Tue, 4 Feb 2020 17:29:20 -0800 Subject: [PATCH] validate group names --- pkg/interface/contacts/src/js/components/new.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/interface/contacts/src/js/components/new.js b/pkg/interface/contacts/src/js/components/new.js index 1891af5895..44a814a577 100644 --- a/pkg/interface/contacts/src/js/components/new.js +++ b/pkg/interface/contacts/src/js/components/new.js @@ -34,13 +34,20 @@ export class NewScreen extends Component { onClickCreate() { const { props, state } = this; - if (!state.groupName) { + + let invalidChara = new RegExp(/[^a-z0-9/-]/); + + if ( + (!state.groupName) || (state.groupName.startsWith("/")) || + (state.groupName.includes("//")) || (invalidChara.test(state.groupName)) + ) { this.setState({ groupNameError: true, inviteError: false }); return; } + let group = `/~${window.ship}` + `/${state.groupName}`; let aud = []; @@ -56,7 +63,7 @@ export class NewScreen extends Component { } }); } - + if (!isValid) { this.setState({ inviteError: true,