Fix empty string comparison issues in the codebase (#16686)
Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
200a56fa5a
Коммит
94c24eea20
@@ -38,11 +38,11 @@ type AccessResponse struct {
|
||||
// correctly.
|
||||
func (ad *AccessData) IsValid() *AppError {
|
||||
|
||||
if len(ad.ClientId) == 0 || len(ad.ClientId) > 26 {
|
||||
if ad.ClientId == "" || len(ad.ClientId) > 26 {
|
||||
return NewAppError("AccessData.IsValid", "model.access.is_valid.client_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(ad.UserId) == 0 || len(ad.UserId) > 26 {
|
||||
if ad.UserId == "" || len(ad.UserId) > 26 {
|
||||
return NewAppError("AccessData.IsValid", "model.access.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (ad *AccessData) IsValid() *AppError {
|
||||
return NewAppError("AccessData.IsValid", "model.access.is_valid.refresh_token.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(ad.RedirectUri) == 0 || len(ad.RedirectUri) > 256 || !IsValidHttpUrl(ad.RedirectUri) {
|
||||
if ad.RedirectUri == "" || len(ad.RedirectUri) > 256 || !IsValidHttpUrl(ad.RedirectUri) {
|
||||
return NewAppError("AccessData.IsValid", "model.access.is_valid.redirect_uri.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ func (ad *AuthData) IsValid() *AppError {
|
||||
return NewAppError("AuthData.IsValid", "model.authorize.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(ad.Code) == 0 || len(ad.Code) > 128 {
|
||||
if ad.Code == "" || len(ad.Code) > 128 {
|
||||
return NewAppError("AuthData.IsValid", "model.authorize.is_valid.auth_code.app_error", nil, "client_id="+ad.ClientId, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -82,11 +82,11 @@ func (ar *AuthorizeRequest) IsValid() *AppError {
|
||||
return NewAppError("AuthData.IsValid", "model.authorize.is_valid.client_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(ar.ResponseType) == 0 {
|
||||
if ar.ResponseType == "" {
|
||||
return NewAppError("AuthData.IsValid", "model.authorize.is_valid.response_type.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(ar.RedirectUri) == 0 || len(ar.RedirectUri) > 256 || !IsValidHttpUrl(ar.RedirectUri) {
|
||||
if ar.RedirectUri == "" || len(ar.RedirectUri) > 256 || !IsValidHttpUrl(ar.RedirectUri) {
|
||||
return NewAppError("AuthData.IsValid", "model.authorize.is_valid.redirect_uri.app_error", nil, "client_id="+ar.ClientId, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ func (ad *AuthData) PreSave() {
|
||||
ad.CreateAt = GetMillis()
|
||||
}
|
||||
|
||||
if len(ad.Scope) == 0 {
|
||||
if ad.Scope == "" {
|
||||
ad.Scope = DEFAULT_SCOPE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func (b *Bot) IsValid() *AppError {
|
||||
return NewAppError("Bot.IsValid", "model.bot.is_valid.description.app_error", b.Trace(), "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(b.OwnerId) == 0 || utf8.RuneCountInString(b.OwnerId) > BOT_CREATOR_ID_MAX_RUNES {
|
||||
if b.OwnerId == "" || utf8.RuneCountInString(b.OwnerId) > BOT_CREATOR_ID_MAX_RUNES {
|
||||
return NewAppError("Bot.IsValid", "model.bot.is_valid.creator_id.app_error", b.Trace(), "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -584,11 +584,11 @@ func (c *Client4) doApiRequestReader(method, url string, data io.Reader, etag st
|
||||
return nil, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(etag) > 0 {
|
||||
if etag != "" {
|
||||
rq.Header.Set(HEADER_ETAG_CLIENT, etag)
|
||||
}
|
||||
|
||||
if len(c.AuthToken) > 0 {
|
||||
if c.AuthToken != "" {
|
||||
rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
@@ -629,7 +629,7 @@ func (c *Client4) doUploadFile(url string, body io.Reader, contentType string, c
|
||||
}
|
||||
rq.Header.Set("Content-Type", contentType)
|
||||
|
||||
if len(c.AuthToken) > 0 {
|
||||
if c.AuthToken != "" {
|
||||
rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ func (c *Client4) DoEmojiUploadFile(url string, data []byte, contentType string)
|
||||
}
|
||||
rq.Header.Set("Content-Type", contentType)
|
||||
|
||||
if len(c.AuthToken) > 0 {
|
||||
if c.AuthToken != "" {
|
||||
rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
@@ -677,7 +677,7 @@ func (c *Client4) DoUploadImportTeam(url string, data []byte, contentType string
|
||||
}
|
||||
rq.Header.Set("Content-Type", contentType)
|
||||
|
||||
if len(c.AuthToken) > 0 {
|
||||
if c.AuthToken != "" {
|
||||
rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
@@ -1490,7 +1490,7 @@ func (c *Client4) SetProfileImage(userId string, data []byte) (bool, *Response)
|
||||
}
|
||||
rq.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
|
||||
if len(c.AuthToken) > 0 {
|
||||
if c.AuthToken != "" {
|
||||
rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
@@ -1739,7 +1739,7 @@ func (c *Client4) SetBotIconImage(botUserId string, data []byte) (bool, *Respons
|
||||
}
|
||||
rq.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
|
||||
if len(c.AuthToken) > 0 {
|
||||
if c.AuthToken != "" {
|
||||
rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
@@ -2273,7 +2273,7 @@ func (c *Client4) SetTeamIcon(teamId string, data []byte) (bool, *Response) {
|
||||
}
|
||||
rq.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
|
||||
if len(c.AuthToken) > 0 {
|
||||
if c.AuthToken != "" {
|
||||
rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
@@ -3471,7 +3471,7 @@ func (c *Client4) UploadLicenseFile(data []byte) (bool, *Response) {
|
||||
}
|
||||
rq.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
|
||||
if len(c.AuthToken) > 0 {
|
||||
if c.AuthToken != "" {
|
||||
rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
@@ -3878,7 +3878,7 @@ func (c *Client4) DownloadComplianceReport(reportId string) ([]byte, *Response)
|
||||
return nil, &Response{Error: NewAppError("DownloadComplianceReport", "model.client.connecting.app_error", nil, err.Error(), http.StatusBadRequest)}
|
||||
}
|
||||
|
||||
if len(c.AuthToken) > 0 {
|
||||
if c.AuthToken != "" {
|
||||
rq.Header.Set(HEADER_AUTH, "BEARER "+c.AuthToken)
|
||||
}
|
||||
|
||||
@@ -4248,7 +4248,7 @@ func (c *Client4) UploadBrandImage(data []byte) (bool, *Response) {
|
||||
}
|
||||
rq.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
|
||||
if len(c.AuthToken) > 0 {
|
||||
if c.AuthToken != "" {
|
||||
rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
@@ -4403,7 +4403,7 @@ func (c *Client4) GetOAuthAccessToken(data url.Values) (*AccessResponse, *Respon
|
||||
}
|
||||
rq.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
||||
if len(c.AuthToken) > 0 {
|
||||
if c.AuthToken != "" {
|
||||
rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
@@ -5042,7 +5042,7 @@ func (c *Client4) uploadPlugin(file io.Reader, force bool) (*Manifest, *Response
|
||||
}
|
||||
rq.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
|
||||
if len(c.AuthToken) > 0 {
|
||||
if c.AuthToken != "" {
|
||||
rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ func (o *ClusterDiscovery) PreSave() {
|
||||
|
||||
func (o *ClusterDiscovery) AutoFillHostname() {
|
||||
// attempt to set the hostname from the OS
|
||||
if len(o.Hostname) == 0 {
|
||||
if o.Hostname == "" {
|
||||
if hn, err := os.Hostname(); err == nil {
|
||||
o.Hostname = hn
|
||||
}
|
||||
@@ -48,8 +48,8 @@ func (o *ClusterDiscovery) AutoFillHostname() {
|
||||
|
||||
func (o *ClusterDiscovery) AutoFillIpAddress(iface string, ipAddress string) {
|
||||
// attempt to set the hostname to the first non-local IP address
|
||||
if len(o.Hostname) == 0 {
|
||||
if len(ipAddress) > 0 {
|
||||
if o.Hostname == "" {
|
||||
if ipAddress != "" {
|
||||
o.Hostname = ipAddress
|
||||
} else {
|
||||
o.Hostname = GetServerIpAddress(iface)
|
||||
@@ -93,15 +93,15 @@ func (o *ClusterDiscovery) IsValid() *AppError {
|
||||
return NewAppError("ClusterDiscovery.IsValid", "model.cluster.is_valid.id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(o.ClusterName) == 0 {
|
||||
if o.ClusterName == "" {
|
||||
return NewAppError("ClusterDiscovery.IsValid", "model.cluster.is_valid.name.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(o.Type) == 0 {
|
||||
if o.Type == "" {
|
||||
return NewAppError("ClusterDiscovery.IsValid", "model.cluster.is_valid.type.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(o.Hostname) == 0 {
|
||||
if o.Hostname == "" {
|
||||
return NewAppError("ClusterDiscovery.IsValid", "model.cluster.is_valid.hostname.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ func (o *Command) IsValid() *AppError {
|
||||
return NewAppError("Command.IsValid", "model.command.is_valid.trigger.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(o.URL) == 0 || len(o.URL) > 1024 {
|
||||
if o.URL == "" || len(o.URL) > 1024 {
|
||||
return NewAppError("Command.IsValid", "model.command.is_valid.url.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ func (c *Compliance) IsValid() *AppError {
|
||||
return NewAppError("Compliance.IsValid", "model.compliance.is_valid.create_at.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(c.Desc) > 512 || len(c.Desc) == 0 {
|
||||
if len(c.Desc) > 512 || c.Desc == "" {
|
||||
return NewAppError("Compliance.IsValid", "model.compliance.is_valid.desc.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -1117,7 +1117,7 @@ func (s *SqlSettings) SetDefaults(isUpdate bool) {
|
||||
|
||||
if isUpdate {
|
||||
// When updating an existing configuration, ensure an encryption key has been specified.
|
||||
if s.AtRestEncryptKey == nil || len(*s.AtRestEncryptKey) == 0 {
|
||||
if s.AtRestEncryptKey == nil || *s.AtRestEncryptKey == "" {
|
||||
s.AtRestEncryptKey = NewString(NewRandomString(32))
|
||||
}
|
||||
} else {
|
||||
@@ -1383,7 +1383,7 @@ func (s *FileSettings) SetDefaults(isUpdate bool) {
|
||||
|
||||
if isUpdate {
|
||||
// When updating an existing configuration, ensure link salt has been specified.
|
||||
if s.PublicLinkSalt == nil || len(*s.PublicLinkSalt) == 0 {
|
||||
if s.PublicLinkSalt == nil || *s.PublicLinkSalt == "" {
|
||||
s.PublicLinkSalt = NewString(NewRandomString(32))
|
||||
}
|
||||
} else {
|
||||
@@ -1416,7 +1416,7 @@ func (s *FileSettings) SetDefaults(isUpdate bool) {
|
||||
s.AmazonS3Region = NewString("")
|
||||
}
|
||||
|
||||
if s.AmazonS3Endpoint == nil || len(*s.AmazonS3Endpoint) == 0 {
|
||||
if s.AmazonS3Endpoint == nil || *s.AmazonS3Endpoint == "" {
|
||||
// Defaults to "s3.amazonaws.com"
|
||||
s.AmazonS3Endpoint = NewString("s3.amazonaws.com")
|
||||
}
|
||||
@@ -1529,11 +1529,11 @@ func (s *EmailSettings) SetDefaults(isUpdate bool) {
|
||||
s.SMTPPassword = NewString("")
|
||||
}
|
||||
|
||||
if s.SMTPServer == nil || len(*s.SMTPServer) == 0 {
|
||||
if s.SMTPServer == nil || *s.SMTPServer == "" {
|
||||
s.SMTPServer = NewString("localhost")
|
||||
}
|
||||
|
||||
if s.SMTPPort == nil || len(*s.SMTPPort) == 0 {
|
||||
if s.SMTPPort == nil || *s.SMTPPort == "" {
|
||||
s.SMTPPort = NewString("10025")
|
||||
}
|
||||
|
||||
@@ -3114,7 +3114,7 @@ func (o *Config) SetDefaults() {
|
||||
}
|
||||
|
||||
func (o *Config) IsValid() *AppError {
|
||||
if len(*o.ServiceSettings.SiteURL) == 0 && *o.EmailSettings.EnableEmailBatching {
|
||||
if *o.ServiceSettings.SiteURL == "" && *o.EmailSettings.EnableEmailBatching {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.site_url_email_batching.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -3122,7 +3122,7 @@ func (o *Config) IsValid() *AppError {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.cluster_email_batching.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(*o.ServiceSettings.SiteURL) == 0 && *o.ServiceSettings.AllowCookiesForSubdomains {
|
||||
if *o.ServiceSettings.SiteURL == "" && *o.ServiceSettings.AllowCookiesForSubdomains {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.allow_cookies_for_subdomains.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -3245,7 +3245,7 @@ func (s *SqlSettings) isValid() *AppError {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.sql_query_timeout.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(*s.DataSource) == 0 {
|
||||
if *s.DataSource == "" {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.sql_data_src.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -3374,47 +3374,47 @@ func (s *LdapSettings) isValid() *AppError {
|
||||
|
||||
func (s *SamlSettings) isValid() *AppError {
|
||||
if *s.Enable {
|
||||
if len(*s.IdpUrl) == 0 || !IsValidHttpUrl(*s.IdpUrl) {
|
||||
if *s.IdpUrl == "" || !IsValidHttpUrl(*s.IdpUrl) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_idp_url.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(*s.IdpDescriptorUrl) == 0 || !IsValidHttpUrl(*s.IdpDescriptorUrl) {
|
||||
if *s.IdpDescriptorUrl == "" || !IsValidHttpUrl(*s.IdpDescriptorUrl) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_idp_descriptor_url.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(*s.IdpCertificateFile) == 0 {
|
||||
if *s.IdpCertificateFile == "" {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_idp_cert.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(*s.EmailAttribute) == 0 {
|
||||
if *s.EmailAttribute == "" {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(*s.UsernameAttribute) == 0 {
|
||||
if *s.UsernameAttribute == "" {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_username_attribute.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(*s.ServiceProviderIdentifier) == 0 {
|
||||
if *s.ServiceProviderIdentifier == "" {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_spidentifier_attribute.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if *s.Verify {
|
||||
if len(*s.AssertionConsumerServiceURL) == 0 || !IsValidHttpUrl(*s.AssertionConsumerServiceURL) {
|
||||
if *s.AssertionConsumerServiceURL == "" || !IsValidHttpUrl(*s.AssertionConsumerServiceURL) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_assertion_consumer_service_url.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
if *s.Encrypt {
|
||||
if len(*s.PrivateKeyFile) == 0 {
|
||||
if *s.PrivateKeyFile == "" {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_private_key.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(*s.PublicCertificateFile) == 0 {
|
||||
if *s.PublicCertificateFile == "" {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_public_cert.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
if len(*s.EmailAttribute) == 0 {
|
||||
if *s.EmailAttribute == "" {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -3425,7 +3425,7 @@ func (s *SamlSettings) isValid() *AppError {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_canonical_algorithm.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(*s.GuestAttribute) > 0 {
|
||||
if *s.GuestAttribute != "" {
|
||||
if !(strings.Contains(*s.GuestAttribute, "=")) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_guest_attribute.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
@@ -3434,7 +3434,7 @@ func (s *SamlSettings) isValid() *AppError {
|
||||
}
|
||||
}
|
||||
|
||||
if len(*s.AdminAttribute) > 0 {
|
||||
if *s.AdminAttribute != "" {
|
||||
if !(strings.Contains(*s.AdminAttribute, "=")) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_admin_attribute.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
@@ -3535,7 +3535,7 @@ func (s *ServiceSettings) isValid() *AppError {
|
||||
|
||||
func (s *ElasticsearchSettings) isValid() *AppError {
|
||||
if *s.EnableIndexing {
|
||||
if len(*s.ConnectionUrl) == 0 {
|
||||
if *s.ConnectionUrl == "" {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.connection_url.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
@@ -3573,7 +3573,7 @@ func (s *ElasticsearchSettings) isValid() *AppError {
|
||||
|
||||
func (bs *BleveSettings) isValid() *AppError {
|
||||
if *bs.EnableIndexing {
|
||||
if len(*bs.IndexDir) == 0 {
|
||||
if *bs.IndexDir == "" {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.bleve_search.filename.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
} else {
|
||||
@@ -3608,7 +3608,7 @@ func (s *DataRetentionSettings) isValid() *AppError {
|
||||
}
|
||||
|
||||
func (s *LocalizationSettings) isValid() *AppError {
|
||||
if len(*s.AvailableLocales) > 0 {
|
||||
if *s.AvailableLocales != "" {
|
||||
if !strings.Contains(*s.AvailableLocales, *s.DefaultClientLocale) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.localization.available_locales.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
@@ -3703,33 +3703,33 @@ func (o *Config) GetSanitizeOptions() map[string]bool {
|
||||
}
|
||||
|
||||
func (o *Config) Sanitize() {
|
||||
if o.LdapSettings.BindPassword != nil && len(*o.LdapSettings.BindPassword) > 0 {
|
||||
if o.LdapSettings.BindPassword != nil && *o.LdapSettings.BindPassword != "" {
|
||||
*o.LdapSettings.BindPassword = FAKE_SETTING
|
||||
}
|
||||
|
||||
*o.FileSettings.PublicLinkSalt = FAKE_SETTING
|
||||
|
||||
if len(*o.FileSettings.AmazonS3SecretAccessKey) > 0 {
|
||||
if *o.FileSettings.AmazonS3SecretAccessKey != "" {
|
||||
*o.FileSettings.AmazonS3SecretAccessKey = FAKE_SETTING
|
||||
}
|
||||
|
||||
if o.EmailSettings.SMTPPassword != nil && len(*o.EmailSettings.SMTPPassword) > 0 {
|
||||
if o.EmailSettings.SMTPPassword != nil && *o.EmailSettings.SMTPPassword != "" {
|
||||
*o.EmailSettings.SMTPPassword = FAKE_SETTING
|
||||
}
|
||||
|
||||
if len(*o.GitLabSettings.Secret) > 0 {
|
||||
if *o.GitLabSettings.Secret != "" {
|
||||
*o.GitLabSettings.Secret = FAKE_SETTING
|
||||
}
|
||||
|
||||
if o.GoogleSettings.Secret != nil && len(*o.GoogleSettings.Secret) > 0 {
|
||||
if o.GoogleSettings.Secret != nil && *o.GoogleSettings.Secret != "" {
|
||||
*o.GoogleSettings.Secret = FAKE_SETTING
|
||||
}
|
||||
|
||||
if o.Office365Settings.Secret != nil && len(*o.Office365Settings.Secret) > 0 {
|
||||
if o.Office365Settings.Secret != nil && *o.Office365Settings.Secret != "" {
|
||||
*o.Office365Settings.Secret = FAKE_SETTING
|
||||
}
|
||||
|
||||
if o.OpenIdSettings.Secret != nil && len(*o.OpenIdSettings.Secret) > 0 {
|
||||
if o.OpenIdSettings.Secret != nil && *o.OpenIdSettings.Secret != "" {
|
||||
*o.OpenIdSettings.Secret = FAKE_SETTING
|
||||
}
|
||||
|
||||
@@ -3746,11 +3746,11 @@ func (o *Config) Sanitize() {
|
||||
o.SqlSettings.DataSourceSearchReplicas[i] = FAKE_SETTING
|
||||
}
|
||||
|
||||
if o.MessageExportSettings.GlobalRelaySettings.SmtpPassword != nil && len(*o.MessageExportSettings.GlobalRelaySettings.SmtpPassword) > 0 {
|
||||
if o.MessageExportSettings.GlobalRelaySettings.SmtpPassword != nil && *o.MessageExportSettings.GlobalRelaySettings.SmtpPassword != "" {
|
||||
*o.MessageExportSettings.GlobalRelaySettings.SmtpPassword = FAKE_SETTING
|
||||
}
|
||||
|
||||
if o.ServiceSettings.GfycatApiSecret != nil && len(*o.ServiceSettings.GfycatApiSecret) > 0 {
|
||||
if o.ServiceSettings.GfycatApiSecret != nil && *o.ServiceSettings.GfycatApiSecret != "" {
|
||||
*o.ServiceSettings.GfycatApiSecret = FAKE_SETTING
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ func (emoji *Emoji) IsValid() *AppError {
|
||||
}
|
||||
|
||||
func IsValidEmojiName(name string) *AppError {
|
||||
if len(name) == 0 || len(name) > EMOJI_NAME_MAX_LENGTH || !IsValidAlphaNumHyphenUnderscore(name, false) || inSystemEmoji(name) {
|
||||
if name == "" || len(name) > EMOJI_NAME_MAX_LENGTH || !IsValidAlphaNumHyphenUnderscore(name, false) || inSystemEmoji(name) {
|
||||
return NewAppError("Emoji.IsValid", "model.emoji.name.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ func (group *Group) IsValidForCreate() *AppError {
|
||||
return NewAppError("Group.IsValidForCreate", "model.group.source.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(group.RemoteId) > GroupRemoteIDMaxLength || (len(group.RemoteId) == 0 && group.requiresRemoteId()) {
|
||||
if len(group.RemoteId) > GroupRemoteIDMaxLength || (group.RemoteId == "" && group.requiresRemoteId()) {
|
||||
return NewAppError("Group.IsValidForCreate", "model.group.remote_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func (i *GuestsInvite) IsValid() *AppError {
|
||||
}
|
||||
|
||||
for _, email := range i.Emails {
|
||||
if len(email) > USER_EMAIL_MAX_LENGTH || len(email) == 0 || !IsValidEmail(email) {
|
||||
if len(email) > USER_EMAIL_MAX_LENGTH || email == "" || !IsValidEmail(email) {
|
||||
return NewAppError("GuestsInvite.IsValid", "model.guest.is_valid.email.app_error", nil, "email="+email, http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ func (lr *LicenseRecord) IsValid() *AppError {
|
||||
return NewAppError("LicenseRecord.IsValid", "model.license_record.is_valid.create_at.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(lr.Bytes) == 0 || len(lr.Bytes) > 10000 {
|
||||
if lr.Bytes == "" || len(lr.Bytes) > 10000 {
|
||||
return NewAppError("LicenseRecord.IsValid", "model.license_record.is_valid.create_at.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -53,11 +53,11 @@ func (a *OAuthApp) IsValid() *AppError {
|
||||
return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.creator_id.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(a.ClientSecret) == 0 || len(a.ClientSecret) > 128 {
|
||||
if a.ClientSecret == "" || len(a.ClientSecret) > 128 {
|
||||
return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.client_secret.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(a.Name) == 0 || len(a.Name) > 64 {
|
||||
if a.Name == "" || len(a.Name) > 64 {
|
||||
return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.name.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ func (a *OAuthApp) IsValid() *AppError {
|
||||
}
|
||||
}
|
||||
|
||||
if len(a.Homepage) == 0 || len(a.Homepage) > 256 || !IsValidHttpUrl(a.Homepage) {
|
||||
if a.Homepage == "" || len(a.Homepage) > 256 || !IsValidHttpUrl(a.Homepage) {
|
||||
return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.homepage.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func (a *OAuthApp) IsValid() *AppError {
|
||||
return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.description.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(a.IconURL) > 0 {
|
||||
if a.IconURL != "" {
|
||||
if len(a.IconURL) > 512 || !IsValidHttpUrl(a.IconURL) {
|
||||
return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.icon_url.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ func (o *OutgoingWebhook) IsValid() *AppError {
|
||||
|
||||
if len(o.TriggerWords) != 0 {
|
||||
for _, triggerWord := range o.TriggerWords {
|
||||
if len(triggerWord) == 0 {
|
||||
if triggerWord == "" {
|
||||
return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.trigger_words.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ func (o *OutgoingWebhook) PreUpdate() {
|
||||
}
|
||||
|
||||
func (o *OutgoingWebhook) TriggerWordExactMatch(word string) bool {
|
||||
if len(word) == 0 {
|
||||
if word == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ func (o *OutgoingWebhook) TriggerWordExactMatch(word string) bool {
|
||||
}
|
||||
|
||||
func (o *OutgoingWebhook) TriggerWordStartsWith(word string) bool {
|
||||
if len(word) == 0 {
|
||||
if word == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ func (o *OutgoingWebhook) TriggerWordStartsWith(word string) bool {
|
||||
}
|
||||
|
||||
func (o *OutgoingWebhook) GetTriggerWord(word string, isExactMatch bool) (triggerWord string) {
|
||||
if len(word) == 0 {
|
||||
if word == "" {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ type PluginKeyValue struct {
|
||||
}
|
||||
|
||||
func (kv *PluginKeyValue) IsValid() *AppError {
|
||||
if len(kv.PluginId) == 0 || utf8.RuneCountInString(kv.PluginId) > KEY_VALUE_PLUGIN_ID_MAX_RUNES {
|
||||
if kv.PluginId == "" || utf8.RuneCountInString(kv.PluginId) > KEY_VALUE_PLUGIN_ID_MAX_RUNES {
|
||||
return NewAppError("PluginKeyValue.IsValid", "model.plugin_key_value.is_valid.plugin_id.app_error", map[string]interface{}{"Max": KEY_VALUE_KEY_MAX_RUNES, "Min": 0}, "key="+kv.Key, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(kv.Key) == 0 || utf8.RuneCountInString(kv.Key) > KEY_VALUE_KEY_MAX_RUNES {
|
||||
if kv.Key == "" || utf8.RuneCountInString(kv.Key) > KEY_VALUE_KEY_MAX_RUNES {
|
||||
return NewAppError("PluginKeyValue.IsValid", "model.plugin_key_value.is_valid.key.app_error", map[string]interface{}{"Max": KEY_VALUE_KEY_MAX_RUNES, "Min": 0}, "key="+kv.Key, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -277,19 +277,19 @@ func (o *Post) IsValid(maxPostSize int) *AppError {
|
||||
return NewAppError("Post.IsValid", "model.post.is_valid.channel_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if !(IsValidId(o.RootId) || len(o.RootId) == 0) {
|
||||
if !(IsValidId(o.RootId) || o.RootId == "") {
|
||||
return NewAppError("Post.IsValid", "model.post.is_valid.root_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if !(IsValidId(o.ParentId) || len(o.ParentId) == 0) {
|
||||
if !(IsValidId(o.ParentId) || o.ParentId == "") {
|
||||
return NewAppError("Post.IsValid", "model.post.is_valid.parent_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(o.ParentId) == 26 && len(o.RootId) == 0 {
|
||||
if len(o.ParentId) == 26 && o.RootId == "" {
|
||||
return NewAppError("Post.IsValid", "model.post.is_valid.root_parent.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if !(len(o.OriginalId) == 26 || len(o.OriginalId) == 0) {
|
||||
if !(len(o.OriginalId) == 26 || o.OriginalId == "") {
|
||||
return NewAppError("Post.IsValid", "model.post.is_valid.original_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ func (o *Preference) IsValid() *AppError {
|
||||
return NewAppError("Preference.IsValid", "model.preference.is_valid.id.app_error", nil, "user_id="+o.UserId, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(o.Category) == 0 || len(o.Category) > 32 {
|
||||
if o.Category == "" || len(o.Category) > 32 {
|
||||
return NewAppError("Preference.IsValid", "model.preference.is_valid.category.app_error", nil, "category="+o.Category, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ func (o *Reaction) IsValid() *AppError {
|
||||
|
||||
validName := regexp.MustCompile(`^[a-zA-Z0-9\-\+_]+$`)
|
||||
|
||||
if len(o.EmojiName) == 0 || len(o.EmojiName) > EMOJI_NAME_MAX_LENGTH || !validName.MatchString(o.EmojiName) {
|
||||
if o.EmojiName == "" || len(o.EmojiName) > EMOJI_NAME_MAX_LENGTH || !validName.MatchString(o.EmojiName) {
|
||||
return NewAppError("Reaction.IsValid", "model.reaction.is_valid.emoji_name.app_error", nil, "emoji_name="+o.EmojiName, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -482,7 +482,7 @@ func (r *Role) IsValidWithoutId() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(r.DisplayName) == 0 || len(r.DisplayName) > ROLE_DISPLAY_NAME_MAX_LENGTH {
|
||||
if r.DisplayName == "" || len(r.DisplayName) > ROLE_DISPLAY_NAME_MAX_LENGTH {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -526,7 +526,7 @@ func CleanRoleNames(roleNames []string) ([]string, bool) {
|
||||
}
|
||||
|
||||
func IsValidRoleName(roleName string) bool {
|
||||
if len(roleName) <= 0 || len(roleName) > ROLE_NAME_MAX_LENGTH {
|
||||
if roleName == "" || len(roleName) > ROLE_NAME_MAX_LENGTH {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ func (scheme *Scheme) IsValid() bool {
|
||||
}
|
||||
|
||||
func (scheme *Scheme) IsValidForCreate() bool {
|
||||
if len(scheme.DisplayName) == 0 || len(scheme.DisplayName) > SCHEME_DISPLAY_NAME_MAX_LENGTH {
|
||||
if scheme.DisplayName == "" || len(scheme.DisplayName) > SCHEME_DISPLAY_NAME_MAX_LENGTH {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ func ParseSearchParams(text string, timeZoneOffset int) []*SearchParams {
|
||||
|
||||
paramsList := []*SearchParams{}
|
||||
|
||||
if len(plainTerms) > 0 || len(excludedPlainTerms) > 0 {
|
||||
if plainTerms != "" || excludedPlainTerms != "" {
|
||||
paramsList = append(paramsList, &SearchParams{
|
||||
Terms: plainTerms,
|
||||
ExcludedTerms: excludedPlainTerms,
|
||||
@@ -333,7 +333,7 @@ func ParseSearchParams(text string, timeZoneOffset int) []*SearchParams {
|
||||
})
|
||||
}
|
||||
|
||||
if len(hashtagTerms) > 0 || len(excludedHashtagTerms) > 0 {
|
||||
if hashtagTerms != "" || excludedHashtagTerms != "" {
|
||||
paramsList = append(paramsList, &SearchParams{
|
||||
Terms: hashtagTerms,
|
||||
ExcludedTerms: excludedHashtagTerms,
|
||||
@@ -355,8 +355,8 @@ func ParseSearchParams(text string, timeZoneOffset int) []*SearchParams {
|
||||
}
|
||||
|
||||
// special case for when no terms are specified but we still have a filter
|
||||
if len(plainTerms) == 0 && len(hashtagTerms) == 0 &&
|
||||
len(excludedPlainTerms) == 0 && len(excludedHashtagTerms) == 0 &&
|
||||
if plainTerms == "" && hashtagTerms == "" &&
|
||||
excludedPlainTerms == "" && excludedHashtagTerms == "" &&
|
||||
(len(inChannels) != 0 || len(fromUsers) != 0 ||
|
||||
len(excludedChannels) != 0 || len(excludedUsers) != 0 ||
|
||||
len(extensions) != 0 || len(excludedExtensions) != 0 ||
|
||||
|
||||
@@ -155,7 +155,7 @@ func (s *Session) GetTeamByTeamId(teamId string) *TeamMember {
|
||||
}
|
||||
|
||||
func (s *Session) IsMobileApp() bool {
|
||||
return len(s.DeviceId) > 0 || s.IsMobile()
|
||||
return s.DeviceId != "" || s.IsMobile()
|
||||
}
|
||||
|
||||
func (s *Session) IsMobile() bool {
|
||||
|
||||
@@ -152,7 +152,7 @@ func (o *Team) IsValid() *AppError {
|
||||
return NewAppError("Team.IsValid", "model.team.is_valid.email.app_error", nil, "id="+o.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(o.Email) > 0 && !IsValidEmail(o.Email) {
|
||||
if o.Email != "" && !IsValidEmail(o.Email) {
|
||||
return NewAppError("Team.IsValid", "model.team.is_valid.email.app_error", nil, "id="+o.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ func (o *Team) IsValid() *AppError {
|
||||
return NewAppError("Team.IsValid", "model.team.is_valid.description.app_error", nil, "id="+o.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(o.InviteId) == 0 {
|
||||
if o.InviteId == "" {
|
||||
return NewAppError("Team.IsValid", "model.team.is_valid.invite_id.app_error", nil, "id="+o.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ func (o *Team) PreSave() {
|
||||
o.Description = SanitizeUnicode(o.Description)
|
||||
o.CompanyName = SanitizeUnicode(o.CompanyName)
|
||||
|
||||
if len(o.InviteId) == 0 {
|
||||
if o.InviteId == "" {
|
||||
o.InviteId = NewId()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ func (u *User) IsValid() *AppError {
|
||||
return InvalidUserError("username", u.Id)
|
||||
}
|
||||
|
||||
if len(u.Email) > USER_EMAIL_MAX_LENGTH || len(u.Email) == 0 || !IsValidEmail(u.Email) {
|
||||
if len(u.Email) > USER_EMAIL_MAX_LENGTH || u.Email == "" || !IsValidEmail(u.Email) {
|
||||
return InvalidUserError("email", u.Id)
|
||||
}
|
||||
|
||||
@@ -298,11 +298,11 @@ func (u *User) IsValid() *AppError {
|
||||
return InvalidUserError("auth_data", u.Id)
|
||||
}
|
||||
|
||||
if u.AuthData != nil && len(*u.AuthData) > 0 && len(u.AuthService) == 0 {
|
||||
if u.AuthData != nil && *u.AuthData != "" && u.AuthService == "" {
|
||||
return InvalidUserError("auth_data_type", u.Id)
|
||||
}
|
||||
|
||||
if len(u.Password) > 0 && u.AuthData != nil && len(*u.AuthData) > 0 {
|
||||
if u.Password != "" && u.AuthData != nil && *u.AuthData != "" {
|
||||
return InvalidUserError("auth_data_pwd", u.Id)
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ func (u *User) PreSave() {
|
||||
u.Timezone = timezones.DefaultUserTimezone()
|
||||
}
|
||||
|
||||
if len(u.Password) > 0 {
|
||||
if u.Password != "" {
|
||||
u.Password = HashPassword(u.Password)
|
||||
}
|
||||
}
|
||||
@@ -414,7 +414,7 @@ func (u *User) PreUpdate() {
|
||||
splitKeys := strings.Split(u.NotifyProps[MENTION_KEYS_NOTIFY_PROP], ",")
|
||||
goodKeys := []string{}
|
||||
for _, key := range splitKeys {
|
||||
if len(key) > 0 {
|
||||
if key != "" {
|
||||
goodKeys = append(goodKeys, strings.ToLower(key))
|
||||
}
|
||||
}
|
||||
@@ -597,11 +597,11 @@ func (u *User) AddNotifyProp(key string, value string) {
|
||||
}
|
||||
|
||||
func (u *User) GetFullName() string {
|
||||
if len(u.FirstName) > 0 && len(u.LastName) > 0 {
|
||||
if u.FirstName != "" && u.LastName != "" {
|
||||
return u.FirstName + " " + u.LastName
|
||||
} else if len(u.FirstName) > 0 {
|
||||
} else if u.FirstName != "" {
|
||||
return u.FirstName
|
||||
} else if len(u.LastName) > 0 {
|
||||
} else if u.LastName != "" {
|
||||
return u.LastName
|
||||
} else {
|
||||
return ""
|
||||
@@ -612,13 +612,13 @@ func (u *User) getDisplayName(baseName, nameFormat string) string {
|
||||
displayName := baseName
|
||||
|
||||
if nameFormat == SHOW_NICKNAME_FULLNAME {
|
||||
if len(u.Nickname) > 0 {
|
||||
if u.Nickname != "" {
|
||||
displayName = u.Nickname
|
||||
} else if fullName := u.GetFullName(); len(fullName) > 0 {
|
||||
} else if fullName := u.GetFullName(); fullName != "" {
|
||||
displayName = fullName
|
||||
}
|
||||
} else if nameFormat == SHOW_FULLNAME {
|
||||
if fullName := u.GetFullName(); len(fullName) > 0 {
|
||||
if fullName := u.GetFullName(); fullName != "" {
|
||||
displayName = fullName
|
||||
}
|
||||
}
|
||||
@@ -768,7 +768,7 @@ func HashPassword(password string) string {
|
||||
// ComparePassword compares the hash
|
||||
func ComparePassword(hash string, password string) bool {
|
||||
|
||||
if len(password) == 0 || len(hash) == 0 {
|
||||
if password == "" || hash == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -881,7 +881,7 @@ func (u *UserWithGroups) GetGroupIDs() []string {
|
||||
return nil
|
||||
}
|
||||
trimmed := strings.TrimSpace(*u.GroupIDs)
|
||||
if len(trimmed) == 0 {
|
||||
if trimmed == "" {
|
||||
return nil
|
||||
}
|
||||
return strings.Split(trimmed, ",")
|
||||
|
||||
@@ -335,7 +335,7 @@ func StringFromJson(data io.Reader) string {
|
||||
|
||||
func GetServerIpAddress(iface string) string {
|
||||
var addrs []net.Addr
|
||||
if len(iface) == 0 {
|
||||
if iface == "" {
|
||||
var err error
|
||||
addrs, err = net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
@@ -495,7 +495,7 @@ func IsFileExtImage(ext string) bool {
|
||||
|
||||
func GetImageMimeType(ext string) string {
|
||||
ext = strings.ToLower(ext)
|
||||
if len(IMAGE_MIME_TYPES[ext]) == 0 {
|
||||
if IMAGE_MIME_TYPES[ext] == "" {
|
||||
return "image"
|
||||
}
|
||||
return IMAGE_MIME_TYPES[ext]
|
||||
|
||||
Ссылка в новой задаче
Block a user