summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/team.go2
-rw-r--r--model/utils.go12
2 files changed, 10 insertions, 4 deletions
diff --git a/model/team.go b/model/team.go
index 6006f738c..8b4f82830 100644
--- a/model/team.go
+++ b/model/team.go
@@ -158,7 +158,7 @@ func IsReservedTeamName(s string) bool {
func IsValidTeamName(s string) bool {
- if !IsValidAlphaNum(s) {
+ if !IsValidAlphaNum(s, false) {
return false
}
diff --git a/model/utils.go b/model/utils.go
index 17d1c6317..d5122e805 100644
--- a/model/utils.go
+++ b/model/utils.go
@@ -202,7 +202,7 @@ func GetSubDomain(s string) (string, string) {
func IsValidChannelIdentifier(s string) bool {
- if !IsValidAlphaNum(s) {
+ if !IsValidAlphaNum(s, true) {
return false
}
@@ -213,10 +213,16 @@ func IsValidChannelIdentifier(s string) bool {
return true
}
+var validAlphaNumUnderscore = regexp.MustCompile(`^[a-z0-9]+([a-z\-\_0-9]+|(__)?)[a-z0-9]+$`)
var validAlphaNum = regexp.MustCompile(`^[a-z0-9]+([a-z\-0-9]+|(__)?)[a-z0-9]+$`)
-func IsValidAlphaNum(s string) bool {
- match := validAlphaNum.MatchString(s)
+func IsValidAlphaNum(s string, allowUnderscores bool) bool {
+ var match bool
+ if allowUnderscores {
+ match = validAlphaNumUnderscore.MatchString(s)
+ } else {
+ match = validAlphaNum.MatchString(s)
+ }
if !match {
return false