Отвечать 400 и 401 вместо 500 на NUL и невалидный UTF-8 во входных данных
This commit is contained in:
@@ -51,6 +51,10 @@ func New(id uuid.UUID, username, displayName string) (User, error) {
|
||||
if utf8.RuneCountInString(displayName) > MaxDisplayNameCodePoints {
|
||||
return User{}, apperr.Invalid(fmt.Sprintf("display_name must be at most %d characters", MaxDisplayNameCodePoints))
|
||||
}
|
||||
// PostgreSQL text cannot hold U+0000.
|
||||
if strings.ContainsRune(displayName, 0) {
|
||||
return User{}, apperr.Invalid("display_name must not contain the NUL character")
|
||||
}
|
||||
return User{
|
||||
ID: id,
|
||||
Username: username,
|
||||
|
||||
Reference in New Issue
Block a user