This commit is contained in:
@@ -69,6 +69,24 @@ class RequestBodies(unittest.TestCase):
|
||||
with self.subTest(path=path, length=len(str(body))):
|
||||
self.assert_invalid(self.api.call("POST", path, [400], actor=self.alice, body=body))
|
||||
|
||||
def test_nul_is_refused_before_it_reaches_the_store(self):
|
||||
"""U+0000 не хранится в `text`: это 400, а не ложная недоступность базы."""
|
||||
nul = "x\u0000y"
|
||||
self.assert_invalid(self.api.call(
|
||||
"POST", "/api/v1/users", [400],
|
||||
body={"username": harness.unique("nul"), "display_name": nul,
|
||||
"password": harness.fresh_password()},
|
||||
))
|
||||
self.assert_invalid(self.api.call(
|
||||
"POST", "/api/v1/chats", [400], actor=self.alice,
|
||||
body={"title": nul, "member_ids": [self.alice["id"]]},
|
||||
))
|
||||
chat = harness.chat(self.api, self.alice, [], title="NUL в сообщении")
|
||||
self.assert_invalid(self.api.call(
|
||||
"POST", "/api/v1/chats/" + chat["id"] + "/messages", [400],
|
||||
actor=self.alice, body={"text": nul},
|
||||
))
|
||||
|
||||
def test_message_text_limits(self):
|
||||
chat = harness.chat(self.api, self.alice, [], title="Лимиты текста")
|
||||
for text in ("x" * 4001, " ", ""):
|
||||
|
||||
Reference in New Issue
Block a user