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