diff --git a/arn/validate/Validate.go b/arn/validate/Validate.go index 08492a88..94de54d1 100644 --- a/arn/validate/Validate.go +++ b/arn/validate/Validate.go @@ -5,6 +5,7 @@ import ( "regexp" "strings" "time" + "unicode/utf8" "github.com/animenotifier/notify.moe/arn/autocorrect" ) @@ -31,6 +32,10 @@ func Nick(nick string) bool { return false } + if !utf8.ValidString(nick) { + return false + } + return nick == autocorrect.UserNick(nick) } diff --git a/arn/validate/Validate_test.go b/arn/validate/Validate_test.go index 33031f6b..b2ccadae 100644 --- a/arn/validate/Validate_test.go +++ b/arn/validate/Validate_test.go @@ -18,6 +18,7 @@ func TestIsValidNick(t *testing.T) { assert.False(t, validate.Nick("Tsun.Dere")) assert.False(t, validate.Nick("Tsun Dere")) assert.False(t, validate.Nick("さとう")) + assert.False(t, validate.Nick(string([]byte{0xff, 0xfe, 0xfd}))) // Valid nicknames assert.True(t, validate.Nick("Tsundere"))