Fix panic with customurlschemes (#9968)
Этот коммит содержится в:
коммит произвёл
Jesse Hallam
родитель
2eaa9e9b35
Коммит
1bac79b9b4
@@ -551,7 +551,7 @@ func (a *App) trackConfig() {
|
|||||||
|
|
||||||
a.SendDiagnostic(TRACK_CONFIG_DISPLAY, map[string]interface{}{
|
a.SendDiagnostic(TRACK_CONFIG_DISPLAY, map[string]interface{}{
|
||||||
"experimental_timezone": *cfg.DisplaySettings.ExperimentalTimezone,
|
"experimental_timezone": *cfg.DisplaySettings.ExperimentalTimezone,
|
||||||
"isdefault_custom_url_schemes": len(*cfg.DisplaySettings.CustomUrlSchemes) != 0,
|
"isdefault_custom_url_schemes": len(cfg.DisplaySettings.CustomUrlSchemes) != 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
a.SendDiagnostic(TRACK_CONFIG_TIMEZONE, map[string]interface{}{
|
a.SendDiagnostic(TRACK_CONFIG_TIMEZONE, map[string]interface{}{
|
||||||
|
|||||||
@@ -1897,14 +1897,14 @@ func (s *MessageExportSettings) SetDefaults() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DisplaySettings struct {
|
type DisplaySettings struct {
|
||||||
CustomUrlSchemes *[]string
|
CustomUrlSchemes []string
|
||||||
ExperimentalTimezone *bool
|
ExperimentalTimezone *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DisplaySettings) SetDefaults() {
|
func (s *DisplaySettings) SetDefaults() {
|
||||||
if s.CustomUrlSchemes == nil {
|
if s.CustomUrlSchemes == nil {
|
||||||
customUrlSchemes := []string{}
|
customUrlSchemes := []string{}
|
||||||
s.CustomUrlSchemes = &customUrlSchemes
|
s.CustomUrlSchemes = customUrlSchemes
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.ExperimentalTimezone == nil {
|
if s.ExperimentalTimezone == nil {
|
||||||
@@ -2495,10 +2495,10 @@ func (mes *MessageExportSettings) isValid(fs FileSettings) *AppError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ds *DisplaySettings) isValid() *AppError {
|
func (ds *DisplaySettings) isValid() *AppError {
|
||||||
if len(*ds.CustomUrlSchemes) != 0 {
|
if len(ds.CustomUrlSchemes) != 0 {
|
||||||
validProtocolPattern := regexp.MustCompile(`(?i)^\s*[a-z][a-z0-9-]*\s*$`)
|
validProtocolPattern := regexp.MustCompile(`(?i)^\s*[a-z][a-z0-9-]*\s*$`)
|
||||||
|
|
||||||
for _, scheme := range *ds.CustomUrlSchemes {
|
for _, scheme := range ds.CustomUrlSchemes {
|
||||||
if !validProtocolPattern.MatchString(scheme) {
|
if !validProtocolPattern.MatchString(scheme) {
|
||||||
return NewAppError(
|
return NewAppError(
|
||||||
"Config.IsValid",
|
"Config.IsValid",
|
||||||
|
|||||||
@@ -512,7 +512,7 @@ func TestDisplaySettingsIsValidCustomUrlSchemes(t *testing.T) {
|
|||||||
ds := &DisplaySettings{}
|
ds := &DisplaySettings{}
|
||||||
ds.SetDefaults()
|
ds.SetDefaults()
|
||||||
|
|
||||||
ds.CustomUrlSchemes = &test.value
|
ds.CustomUrlSchemes = test.value
|
||||||
|
|
||||||
if err := ds.isValid(); err != nil && test.valid {
|
if err := ds.isValid(); err != nil && test.valid {
|
||||||
t.Error("Expected CustomUrlSchemes to be valid but got error:", err)
|
t.Error("Expected CustomUrlSchemes to be valid but got error:", err)
|
||||||
|
|||||||
@@ -625,7 +625,7 @@ func GenerateClientConfig(c *model.Config, diagnosticId string, license *model.L
|
|||||||
props["PasswordRequireUppercase"] = strconv.FormatBool(*c.PasswordSettings.Uppercase)
|
props["PasswordRequireUppercase"] = strconv.FormatBool(*c.PasswordSettings.Uppercase)
|
||||||
props["PasswordRequireNumber"] = strconv.FormatBool(*c.PasswordSettings.Number)
|
props["PasswordRequireNumber"] = strconv.FormatBool(*c.PasswordSettings.Number)
|
||||||
props["PasswordRequireSymbol"] = strconv.FormatBool(*c.PasswordSettings.Symbol)
|
props["PasswordRequireSymbol"] = strconv.FormatBool(*c.PasswordSettings.Symbol)
|
||||||
props["CustomUrlSchemes"] = strings.Join(*c.DisplaySettings.CustomUrlSchemes, ",")
|
props["CustomUrlSchemes"] = strings.Join(c.DisplaySettings.CustomUrlSchemes, ",")
|
||||||
|
|
||||||
if license != nil {
|
if license != nil {
|
||||||
props["ExperimentalHideTownSquareinLHS"] = strconv.FormatBool(*c.TeamSettings.ExperimentalHideTownSquareinLHS)
|
props["ExperimentalHideTownSquareinLHS"] = strconv.FormatBool(*c.TeamSettings.ExperimentalHideTownSquareinLHS)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user