diff --git a/internal/regexes/regexes.go b/internal/regexes/regexes.go index fe44980c5..88c832508 100644 --- a/internal/regexes/regexes.go +++ b/internal/regexes/regexes.go @@ -47,8 +47,8 @@ mentionFinder = `(?:^|\s)(@` + usernameGrp + `+(?:@` + domainGrp + `+)?)` // Extract all mentions from a text, each mention may include domain. emojiShortcode = `\w{2,30}` // Pattern for emoji shortcodes. maximumEmojiShortcodeLength = 30 emojiFinder = `(?:\b)?:(` + emojiShortcode + `):(?:\b)?` // Extract all emoji shortcodes from a text. - usernameStrict = `^[a-z0-9_]{2,64}$` // Pattern for usernames on THIS instance. maximumUsernameLength = 64 - usernameRelaxed = `[a-z0-9_\.]{2,}` // Relaxed version of username that can match instance accounts too. + usernameStrict = `^[a-z0-9_]{1,64}$` // Pattern for usernames on THIS instance. maximumUsernameLength = 64 + usernameRelaxed = `[a-z0-9_\.]{1,}` // Relaxed version of username that can match instance accounts too. misskeyReportNotesFinder = `(?m)(?:^Note: ((?:http|https):\/\/.*)$)` // Extract reported Note URIs from the text of a Misskey report/flag. ulid = `[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}` // Pattern for ULID. ulidValidate = `^` + ulid + `$` // Validate one ULID. diff --git a/internal/validate/formvalidation_test.go b/internal/validate/formvalidation_test.go index 9cfa07700..4dff5b60d 100644 --- a/internal/validate/formvalidation_test.go +++ b/internal/validate/formvalidation_test.go @@ -93,6 +93,7 @@ func (suite *ValidationTestSuite) TestValidateUsername() { trailingSpace := "thisusername_ends_with_a_space " newlines := "this_is\n_almost_ok" goodUsername := "this_is_a_good_username" + singleChar := "s" var err error err = validate.Username(empty) @@ -118,6 +119,9 @@ func (suite *ValidationTestSuite) TestValidateUsername() { err = validate.Username(goodUsername) suite.NoError(err) + + err = validate.Username(singleChar) + suite.NoError(err) } func (suite *ValidationTestSuite) TestValidateEmail() {