filter characters in upstream nicks, to just alphanumeric

This commit is contained in:
mappu 2018-06-04 16:47:07 +12:00
parent f4025ad513
commit 3752fce714
1 changed files with 4 additions and 0 deletions

View File

@ -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))