Prominent payload limit error and configurable URL length limit (#27747)
* Added context error handler for MaxBytesError * Made URL length limit configurable * Added tests * Removed an unused function * Typo
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a0a79b4575
Коммит
79480494d0
@@ -112,6 +112,7 @@ const (
|
||||
ServiceSettingsDefaultGiphySdkKeyTest = "s0glxvzVg9azvPipKxcPLpXV0q1x1fVP"
|
||||
ServiceSettingsDefaultDeveloperFlags = ""
|
||||
ServiceSettingsDefaultUniqueReactionsPerPost = 50
|
||||
ServiceSettingsDefaultMaxURLLength = 2048
|
||||
ServiceSettingsMaxUniqueReactionsPerPost = 500
|
||||
|
||||
TeamSettingsDefaultSiteName = "Mattermost"
|
||||
@@ -410,6 +411,7 @@ type ServiceSettings struct {
|
||||
UniqueEmojiReactionLimitPerPost *int `access:"site_posts"`
|
||||
RefreshPostStatsRunTime *string `access:"site_users_and_teams"`
|
||||
MaximumPayloadSizeBytes *int64 `access:"environment_file_storage,write_restrictable,cloud_restrictable"`
|
||||
MaximumURLLength *int `access:"environment_file_storage,write_restrictable,cloud_restrictable"`
|
||||
}
|
||||
|
||||
var MattermostGiphySdkKey string
|
||||
@@ -921,6 +923,10 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
|
||||
if s.MaximumPayloadSizeBytes == nil {
|
||||
s.MaximumPayloadSizeBytes = NewInt64(300000)
|
||||
}
|
||||
|
||||
if s.MaximumURLLength == nil {
|
||||
s.MaximumURLLength = NewInt(ServiceSettingsDefaultMaxURLLength)
|
||||
}
|
||||
}
|
||||
|
||||
type ClusterSettings struct {
|
||||
@@ -4031,6 +4037,10 @@ func (s *ServiceSettings) isValid() *AppError {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.max_payload_size.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if *s.MaximumURLLength <= 0 {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.max_url_length.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if *s.ReadTimeout <= 0 {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.read_timeout.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user