diff options
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server/v6/model/utils.go')
-rw-r--r-- | vendor/github.com/mattermost/mattermost-server/v6/model/utils.go | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go b/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go index 4a6f633e..636e707e 100644 --- a/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go +++ b/vendor/github.com/mattermost/mattermost-server/v6/model/utils.go @@ -33,6 +33,7 @@ const ( UppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" NUMBERS = "0123456789" SYMBOLS = " !\"\\#$%&'()*+,-./:;<=>?@[]^_`|~" + BinaryParamKey = "MM_BINARY_PARAMETERS" ) type StringInterface map[string]interface{} @@ -124,12 +125,19 @@ func (m *StringMap) Scan(value interface{}) error { // Value converts StringMap to database value func (m StringMap) Value() (driver.Value, error) { - j, err := json.Marshal(m) + ok := m[BinaryParamKey] + delete(m, BinaryParamKey) + buf, err := json.Marshal(m) if err != nil { return nil, err } - // non utf8 characters are not supported https://mattermost.atlassian.net/browse/MM-41066 - return string(j), err + if ok == "true" { + return append([]byte{0x01}, buf...), nil + } else if ok == "false" { + return buf, nil + } + // Key wasn't found. We fall back to the default case. + return string(buf), nil } func (StringMap) ImplementsGraphQLType(name string) bool { @@ -502,21 +510,13 @@ var reservedName = []string{ } func IsValidChannelIdentifier(s string) bool { - - if !IsValidAlphaNumHyphenUnderscore(s, true) { - return false - } - - if len(s) < ChannelNameMinLength { - return false - } - - return true + return validSimpleAlphaNum.MatchString(s) && len(s) >= ChannelNameMinLength } var ( validAlphaNum = regexp.MustCompile(`^[a-z0-9]+([a-z\-0-9]+|(__)?)[a-z0-9]+$`) validAlphaNumHyphenUnderscore = regexp.MustCompile(`^[a-z0-9]+([a-z\-\_0-9]+|(__)?)[a-z0-9]+$`) + validSimpleAlphaNum = regexp.MustCompile(`^[a-z0-9]+([a-z\-\_0-9]+|(__)?)[a-z0-9]*$`) validSimpleAlphaNumHyphenUnderscore = regexp.MustCompile(`^[a-zA-Z0-9\-_]+$`) validSimpleAlphaNumHyphenUnderscorePlus = regexp.MustCompile(`^[a-zA-Z0-9+_-]+$`) ) |