mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
ircs2s_common: don't strip away other whitespace chars when tokenizing
This commit is contained in:
parent
3f59dcd884
commit
bc3a7abe02
@ -97,7 +97,7 @@ class IRCCommonProtocol(IRCNetwork):
|
|||||||
joined_arg = ' '.join(args[idx:])[1:] # Cut off the leading : as well
|
joined_arg = ' '.join(args[idx:])[1:] # Cut off the leading : as well
|
||||||
real_args.append(joined_arg)
|
real_args.append(joined_arg)
|
||||||
break
|
break
|
||||||
elif arg.strip(): # Skip empty args that aren't part of the multi-word arg
|
elif arg.strip(' '): # Skip empty args that aren't part of the multi-word arg
|
||||||
real_args.append(arg)
|
real_args.append(arg)
|
||||||
|
|
||||||
return real_args
|
return real_args
|
||||||
|
@ -29,7 +29,7 @@ class DummySocket():
|
|||||||
return None
|
return None
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def recv(bufsize, *args):
|
def recv(self, bufsize, *args):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def send(self, data):
|
def send(self, data):
|
||||||
@ -343,7 +343,7 @@ class BaseProtocolTest(unittest.TestCase):
|
|||||||
[('+v', '100'), ('+i', None), ('+p', None)]
|
[('+v', '100'), ('+i', None), ('+p', None)]
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_parse_modes_channel_rfc(self):
|
def test_parse_modes_channel_rfc2(self):
|
||||||
# These are basic tests that only use RFC 1459 defined modes.
|
# These are basic tests that only use RFC 1459 defined modes.
|
||||||
# IRCds supporting more complex modes can define new test cases if needed.
|
# IRCds supporting more complex modes can define new test cases if needed.
|
||||||
c = self.p.channels['#testruns'] = Channel(self.p, name='#testruns')
|
c = self.p.channels['#testruns'] = Channel(self.p, name='#testruns')
|
||||||
|
@ -111,5 +111,16 @@ class MessageParserTest(unittest.TestCase):
|
|||||||
|
|
||||||
# N.B. skipping msg-join tests because PyLink doesn't think about messages that way
|
# N.B. skipping msg-join tests because PyLink doesn't think about messages that way
|
||||||
|
|
||||||
|
### Custom test cases
|
||||||
|
def testMessageSplitSpaces(self):
|
||||||
|
# Test that tokenization ignores empty fields, but doesn't strip away other types of whitespace
|
||||||
|
f = IRCCommonProtocol.parse_prefixed_args
|
||||||
|
self.assertEqual(f(":foo PRIVMSG #test :message"), ["foo", "PRIVMSG", "#test", "message"])
|
||||||
|
self.assertEqual(f(":123LOLWUT NICK cursed\u3000nickname"), ["123LOLWUT", "NICK", "cursed\u3000nickname"])
|
||||||
|
self.assertEqual(f(":123LOLWUT MODE ## +ov \x1f checking"),
|
||||||
|
["123LOLWUT", "MODE", "##", "+ov", "\x1f", "checking"])
|
||||||
|
self.assertEqual(f(":123LOLWUT MODE ## +ov \u3000 checking"),
|
||||||
|
["123LOLWUT", "MODE", "##", "+ov", "\u3000", "checking"])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user