Validating channel name when connecting.

This commit is contained in:
claudemiro
2015-05-17 09:51:17 -03:00
parent 485bc01abe
commit e2d07e9760
3 changed files with 38 additions and 0 deletions
+15
View File
@@ -10,6 +10,7 @@ import (
"encoding/hex"
"fmt"
"math/rand"
"regexp"
"time"
)
@@ -29,3 +30,17 @@ func GenerateSessionID() string {
return fmt.Sprintf("%d.%d", rand.Intn(MAX), rand.Intn(MAX))
}
func IsChannelNameValid(channelName string) bool {
matched, err := regexp.MatchString("^[A-Za-z0-9_\\-=@,.;]+$", channelName)
if err != nil {
return false
}
if matched {
return true
}
return false
}