From 3752fce714ecd69548c21c86c92eeaf0ffbac6de Mon Sep 17 00:00:00 2001 From: mappu Date: Mon, 4 Jun 2018 16:47:07 +1200 Subject: [PATCH] filter characters in upstream nicks, to just alphanumeric --- NTFServer.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NTFServer.go b/NTFServer.go index 3d4e74c..cf9d20c 100644 --- a/NTFServer.go +++ b/NTFServer.go @@ -5,6 +5,7 @@ import ( "fmt" "html" "log" + "regexp" "sort" "strings" "sync" @@ -545,6 +546,9 @@ func (this *NTFServer) HandleDirectMessage(update telegram.Update) error { } else if strings.HasPrefix(msg, "/join ") { requestedHubNick := msg[6:] + // Some users take the [] in the message literally. A-Za-z0-9 are the only supported characters + requestedHubNick = regexp.MustCompile(`[^a-zA-Z0-9]`).ReplaceAllString(requestedHubNick, "") + // Minimum nick lengths if len(requestedHubNick) < this.config.HubNickMinChars { return respond(fmt.Sprintf("Upstream nickname '%s' should be at least %d characters long", requestedHubNick, this.config.HubNickMinChars))