mirror of https://github.com/jesopo/irctokens
truncate on \r and \n too
This commit is contained in:
parent
93f1079ae7
commit
14d38192cf
|
@ -109,7 +109,10 @@ def tokenise(
|
|||
else:
|
||||
dline = line
|
||||
|
||||
if "\x00" in dline:
|
||||
dline, _ = dline.split("\x00", 1)
|
||||
for badchar in set(dline) & {"\x00", "\r", "\n"}:
|
||||
badindex = dline.find(badchar)
|
||||
if not badindex == -1:
|
||||
# truncate before this bad character
|
||||
dline = dline[:badindex]
|
||||
|
||||
return _tokenise(dline)
|
||||
|
|
|
@ -71,12 +71,22 @@ class TokenTestAll(unittest.TestCase):
|
|||
self.assertEqual(line.command, "PRIVMSG")
|
||||
self.assertEqual(line.params, ["#channel", "hello world"])
|
||||
|
||||
class TokenTestNul(unittest.TestCase):
|
||||
def test(self):
|
||||
class TokenTestTruncate(unittest.TestCase):
|
||||
def test_null(self):
|
||||
line = irctokens.tokenise(
|
||||
":nick!user@host PRIVMSG #channel :hello\x00 world")
|
||||
self.assertEqual(line.params, ["#channel", "hello"])
|
||||
|
||||
def test_cr(self):
|
||||
line = irctokens.tokenise(
|
||||
":nick!user@host PRIVMSG #channel :hello\r world")
|
||||
self.assertEqual(line.params, ["#channel", "hello"])
|
||||
|
||||
def test_lf(self):
|
||||
line = irctokens.tokenise(
|
||||
":nick!user@host PRIVMSG #channel :hello\n world")
|
||||
self.assertEqual(line.params, ["#channel", "hello"])
|
||||
|
||||
class TokenTestNoCommand(unittest.TestCase):
|
||||
def test(self):
|
||||
def _test1():
|
||||
|
|
Loading…
Reference in New Issue