Validating channel name when connecting.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user