Отвечать 400 и 401 вместо 500 на NUL и невалидный UTF-8 во входных данных

This commit is contained in:
2026-10-06 15:41:36 +03:00
parent 8f9252a5c1
commit 3001507ecb
10 changed files with 34 additions and 5 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ func TestNewMessageValidatesTextByCodePoints(t *testing.T) {
if _, err := chat.NewMessage(ident.New(), chatID, alice, strings.Repeat("я", 4000)); err != nil {
t.Errorf("4000 code points must be accepted: %v", err)
}
for _, text := range []string{"", " ", "\n\t ", strings.Repeat("я", 4001)} {
for _, text := range []string{"", " ", "\n\t ", strings.Repeat("я", 4001), "nul\x00inside"} {
_, err := chat.NewMessage(ident.New(), chatID, alice, text)
if apperr.KindOf(err) != apperr.KindInvalid {
t.Errorf("text %q must be rejected as invalid, got %v", text, err)