diff --git a/internal/common/protocol_test.go b/internal/common/protocol_test.go index f6a0be75..9b4c0d1a 100644 --- a/internal/common/protocol_test.go +++ b/internal/common/protocol_test.go @@ -5775,7 +5775,7 @@ func TestBackupAsAttachment(t *testing.T) { require.NoError(t, err) a1 := dataprovider.BaseEventAction{ - Name: "a1", + Name: "a1 with space", Type: dataprovider.ActionTypeBackup, } a2 := dataprovider.BaseEventAction{ diff --git a/internal/dataprovider/eventrule.go b/internal/dataprovider/eventrule.go index d151fa8c..959f874c 100644 --- a/internal/dataprovider/eventrule.go +++ b/internal/dataprovider/eventrule.go @@ -1256,6 +1256,12 @@ func (a *BaseEventAction) validate() error { if !util.IsNameValid(a.Name) { return util.NewI18nError(errInvalidInput, util.I18nErrorInvalidInput) } + if config.NamingRules&1 == 0 && !usernameRegex.MatchString(a.Name) { + return util.NewI18nError( + util.NewValidationError(fmt.Sprintf("name %q is not valid, the following characters are allowed: a-zA-Z0-9-_.~", a.Name)), + util.I18nErrorInvalidUser, + ) + } if !isActionTypeValid(a.Type) { return util.NewValidationError(fmt.Sprintf("invalid action type: %d", a.Type)) } @@ -1682,6 +1688,12 @@ func (r *EventRule) validate() error { //nolint:gocyclo if !util.IsNameValid(r.Name) { return util.NewI18nError(errInvalidInput, util.I18nErrorInvalidInput) } + if config.NamingRules&1 == 0 && !usernameRegex.MatchString(r.Name) { + return util.NewI18nError( + util.NewValidationError(fmt.Sprintf("name %q is not valid, the following characters are allowed: a-zA-Z0-9-_.~", r.Name)), + util.I18nErrorInvalidUser, + ) + } if !r.isStatusValid() { return util.NewValidationError(fmt.Sprintf("invalid event rule status: %d", r.Status)) } diff --git a/internal/httpd/httpd_test.go b/internal/httpd/httpd_test.go index 0b11aa8b..f0f40469 100644 --- a/internal/httpd/httpd_test.go +++ b/internal/httpd/httpd_test.go @@ -2146,7 +2146,7 @@ func TestIPListEntriesValidation(t *testing.T) { } func TestBasicActionRulesHandling(t *testing.T) { - actionName := "test action" + actionName := "test_action" a := dataprovider.BaseEventAction{ Name: actionName, Description: "test description", @@ -2286,7 +2286,7 @@ func TestBasicActionRulesHandling(t *testing.T) { assert.Equal(t, defaultPassword, dbAction.Options.HTTPConfig.Password.GetPayload()) r := dataprovider.EventRule{ - Name: "test rule name", + Name: "test_rule_name", Status: 1, Description: "", Trigger: dataprovider.EventTriggerFsEvent, @@ -2548,7 +2548,7 @@ func TestActionRuleRelations(t *testing.T) { } func TestOnDemandEventRules(t *testing.T) { - ruleName := "test on demand rule" + ruleName := "test_on_demand_rule" a := dataprovider.BaseEventAction{ Name: "a", Type: dataprovider.ActionTypeBackup, @@ -2589,7 +2589,7 @@ func TestOnDemandEventRules(t *testing.T) { } func TestIDPLoginEventRule(t *testing.T) { - ruleName := "test IDP login rule" + ruleName := "test_IDP_login_rule" a := dataprovider.BaseEventAction{ Name: "a", Type: dataprovider.ActionTypeIDPAccountCheck, @@ -7929,7 +7929,7 @@ func TestProviderErrors(t *testing.T) { backupData = dataprovider.BackupData{ EventActions: []dataprovider.BaseEventAction{ { - Name: "quota reset", + Name: "quota_reset", Type: dataprovider.ActionTypeFolderQuotaReset, }, }, @@ -7944,7 +7944,7 @@ func TestProviderErrors(t *testing.T) { backupData = dataprovider.BackupData{ EventRules: []dataprovider.EventRule{ { - Name: "quota reset", + Name: "quota_reset", Trigger: dataprovider.EventTriggerSchedule, Conditions: dataprovider.EventConditions{ Schedules: []dataprovider.Schedule{ @@ -8738,7 +8738,7 @@ func TestLoaddata(t *testing.T) { } action := dataprovider.BaseEventAction{ ID: 81, - Name: "test restore action", + Name: "test_restore_action", Type: dataprovider.ActionTypeHTTP, Options: dataprovider.BaseEventActionOptions{ HTTPConfig: dataprovider.EventActionHTTPConfig{ @@ -8754,7 +8754,7 @@ func TestLoaddata(t *testing.T) { } rule := dataprovider.EventRule{ ID: 100, - Name: "test rule restore", + Name: "test_rule_restore", Description: "", Trigger: dataprovider.EventTriggerFsEvent, Conditions: dataprovider.EventConditions{ @@ -9119,7 +9119,7 @@ func TestLoaddataMode(t *testing.T) { } action := dataprovider.BaseEventAction{ ID: 81, - Name: "test restore action data mode", + Name: "test_restore_action_data_mode", Description: "action desc", Type: dataprovider.ActionTypeHTTP, Options: dataprovider.BaseEventActionOptions{ @@ -9136,7 +9136,7 @@ func TestLoaddataMode(t *testing.T) { } rule := dataprovider.EventRule{ ID: 100, - Name: "test rule restore data mode", + Name: "test_rule_restore_data_mode", Description: "rule desc", Trigger: dataprovider.EventTriggerFsEvent, Conditions: dataprovider.EventConditions{ @@ -9643,7 +9643,7 @@ func TestEventRuleErrorsMock(t *testing.T) { checkResponseCode(t, http.StatusBadRequest, rr) a := dataprovider.BaseEventAction{ - Name: "action name", + Name: "action_name", Description: "test description", Type: dataprovider.ActionTypeBackup, Options: dataprovider.BaseEventActionOptions{}, @@ -9658,7 +9658,7 @@ func TestEventRuleErrorsMock(t *testing.T) { checkResponseCode(t, http.StatusBadRequest, rr) r := dataprovider.EventRule{ - Name: "test event rule", + Name: "test_event_rule", Trigger: dataprovider.EventTriggerSchedule, Conditions: dataprovider.EventConditions{ Schedules: []dataprovider.Schedule{ diff --git a/internal/httpd/internal_test.go b/internal/httpd/internal_test.go index ccc0213e..4a17fa5e 100644 --- a/internal/httpd/internal_test.go +++ b/internal/httpd/internal_test.go @@ -1414,7 +1414,7 @@ func TestCreateShareCookieError(t *testing.T) { err := dataprovider.AddUser(user, "", "", "") assert.NoError(t, err) share := &dataprovider.Share{ - Name: "test share cookie error", + Name: "test_share_cookie_error", ShareID: util.GenerateUniqueID(), Scope: dataprovider.ShareScopeRead, Password: pwd, diff --git a/static/locales/de/translation.json b/static/locales/de/translation.json index bb41baf9..c439793f 100644 --- a/static/locales/de/translation.json +++ b/static/locales/de/translation.json @@ -500,7 +500,7 @@ "user": { "view_manage": "Benutzer anzeigen und verwalten", "username_reserved": "Der angegebene Benutzername ist reserviert", - "username_invalid": "Der angegebene Benutzername ist ungültig, die folgenden Zeichen sind erlaubt: a-zA-Z0-9-_.~", + "username_invalid": "Der angegebene Name ist ungültig. Die folgenden Zeichen sind zulässig: a-z A-Z 0-9 - _ . ~", "home_required": "Das Home-Verzeichnis ist obligatorisch", "home_invalid": "Das Home-Verzeichnis muss ein absoluter Pfad sein", "pub_key_invalid": "Ungültiger öffentlicher Schlüssel", diff --git a/static/locales/en/translation.json b/static/locales/en/translation.json index 37bd4511..040a0ad4 100644 --- a/static/locales/en/translation.json +++ b/static/locales/en/translation.json @@ -500,7 +500,7 @@ "user": { "view_manage": "View and manage users", "username_reserved": "The specified username is reserved", - "username_invalid": "The specified username is not valid, the following characters are allowed: a-zA-Z0-9-_.~", + "username_invalid": "The specified name is not valid, the following characters are allowed: a-z A-Z 0-9 - _ . ~", "home_required": "The home directory is mandatory", "home_invalid": "The home directory must be an absolute path", "pub_key_invalid": "Invalid public key", diff --git a/static/locales/fr/translation.json b/static/locales/fr/translation.json index dd1e0f56..cbc12e27 100644 --- a/static/locales/fr/translation.json +++ b/static/locales/fr/translation.json @@ -500,7 +500,7 @@ "user": { "view_manage": "Voir et gérer les utilisateurs", "username_reserved": "Le nom d'utilisateur spécifié est réservé", - "username_invalid": "Le nom d'utilisateur spécifié n'est pas valide, les caractères suivants sont autorisés : a-zA-Z0-9-_.~", + "username_invalid": "Le nom indiqué n’est pas valide. Les caractères suivants sont autorisés : a-z A-Z 0-9 - _ . ~", "home_required": "Le répertoire de base est obligatoire", "home_invalid": "Le répertoire de base doit être un chemin absolu", "pub_key_invalid": "Clé publique invalide", diff --git a/static/locales/it/translation.json b/static/locales/it/translation.json index 94f0e7c5..a557096c 100644 --- a/static/locales/it/translation.json +++ b/static/locales/it/translation.json @@ -500,7 +500,7 @@ "user": { "view_manage": "Visualizza e gestisci utenti", "username_reserved": "Il nome utente specificato è riservato", - "username_invalid": "Il nome utente specificato non è valido, sono consentiti i seguenti caratteri: a-zA-Z0-9-_.~", + "username_invalid": "Il nome specificato non è valido. Sono consentiti i seguenti caratteri: a-z A-Z 0-9 - _ . ~", "home_required": "La directory principale è obbligatoria", "home_invalid": "La directory principale deve essere un path assoluto", "pub_key_invalid": "Chiave pubblica non valida",