diff --git a/web/service/inbound.go b/web/service/inbound.go index 822a4e8d8a..1450dd5738 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -2,9 +2,7 @@ package service import ( "encoding/json" - "errors" "fmt" - "regexp" "strconv" "strings" "time" @@ -101,8 +99,9 @@ func (s *InboundService) getAllEmails() ([]string, error) { } func (s *InboundService) contains(slice []string, str string) bool { + lowerStr := strings.ToLower(str) for _, s := range slice { - if s == str { + if strings.ToLower(s) == lowerStr { return true } } @@ -414,12 +413,6 @@ func (s *InboundService) AddInboundClient(data *model.Inbound) (bool, error) { return false, err } - email := clients[0].Email - valid, err := validateEmail(email) - if !valid { - return false, err - } - var settings map[string]interface{} err = json.Unmarshal([]byte(data.Settings), &settings) if err != nil { @@ -610,12 +603,6 @@ func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId strin return false, err } - email := clients[0].Email - valid, err := validateEmail(email) - if !valid { - return false, err - } - var settings map[string]interface{} err = json.Unmarshal([]byte(data.Settings), &settings) if err != nil { @@ -2022,26 +2009,3 @@ func (s *InboundService) MigrateDB() { func (s *InboundService) GetOnlineClients() []string { return p.GetOnlineClients() } - -func validateEmail(email string) (bool, error) { - - if strings.Contains(email, " ") { - return false, errors.New("email contains spaces, please remove them") - } - - if email != strings.ToLower(email) { - return false, errors.New("email contains uppercase letters, please convert to lowercase") - } - - nonEnglishPattern := `[^\x00-\x7F]` - if regexp.MustCompile(nonEnglishPattern).MatchString(email) { - return false, errors.New("email contains non-English characters, please use only English") - } - - emailPattern := `^[a-z0-9@._-]+$` - if !regexp.MustCompile(emailPattern).MatchString(email) { - return false, errors.New("email contains invalid characters, please use only lowercase letters, digits, and @._-") - } - - return true, nil -}