From 9f8e71277685c2c0d07154e4953ceb05cab542e1 Mon Sep 17 00:00:00 2001 From: Val Lorentz Date: Fri, 19 Apr 2024 15:13:51 +0200 Subject: [PATCH] testNonutf8Realname/testNonutf8Username: Add support for ERROR instead of FAIL/ERR_INVALIDUSERNAME This is what Sable does, at it fails to decode non-UTF8 data before it even tries to parse commands. --- irctest/server_tests/utf8.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/irctest/server_tests/utf8.py b/irctest/server_tests/utf8.py index cc133fa..c917362 100644 --- a/irctest/server_tests/utf8.py +++ b/irctest/server_tests/utf8.py @@ -57,8 +57,16 @@ class Utf8TestCase(cases.BaseServerTestCase): self.sendLine(2, "NICK bar") self.clients[2].conn.sendall(b"USER username * * :i\xe8rc\xe9\r\n") - d = self.clients[2].conn.recv(1024) - if b"FAIL " in d or b"468 " in d: # ERR_INVALIDUSERNAME + d = b"" + while True: + try: + buf = self.clients[2].conn.recv(1024) + except TimeoutError: + break + if d and not buf: + break + d += buf + if b"FAIL " in d or b"ERROR " in d or b"468 " in d: # ERR_INVALIDUSERNAME return # nothing more to test self.assertIn(b"001 ", d) @@ -74,8 +82,16 @@ class Utf8TestCase(cases.BaseServerTestCase): self.sendLine(2, "NICK bar") self.clients[2].conn.sendall(b"USER \xe8rc\xe9 * * :readlname\r\n") - d = self.clients[2].conn.recv(1024) - if b"FAIL " in d or b"468 " in d: # ERR_INVALIDUSERNAME + d = b"" + while True: + try: + buf = self.clients[2].conn.recv(1024) + except TimeoutError: + break + if d and not buf: + break + d += buf + if b"FAIL " in d or b"ERROR " in d or b"468 " in d: # ERR_INVALIDUSERNAME return # nothing more to test self.assertIn(b"001 ", d)