3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 21:19:31 +01:00

Correction: it is legal for a server name to end with '.', but it can't start with it

This commit is contained in:
James Lu 2015-07-07 14:31:47 -07:00
parent cfc840ebb3
commit 098b29ae2d
3 changed files with 4 additions and 6 deletions

View File

@ -156,7 +156,6 @@ def handle_ping(irc, source, command, args):
_sendFromServer(irc, args[1], 'PONG %s %s' % (args[1], source))
def handle_privmsg(irc, source, command, args):
prefix = irc.conf['bot']['prefix']
if args[0] == irc.pseudoclient.uid:
cmd_args = args[1].split(' ')
cmd = cmd_args[0].lower()

View File

@ -51,13 +51,13 @@ class TestUtils(unittest.TestCase):
self.assertTrue(utils.isChannel('##ABCD'))
def testIsServerName(self):
self.assertFalse(utils.isServerName('s'))
self.assertFalse(utils.isServerName('s.'))
self.assertFalse(utils.isServerName('Invalid'))
self.assertTrue(utils.isServerName('services.'))
self.assertFalse(utils.isServerName('.s.s.s'))
self.assertTrue(utils.isServerName('Hello.world'))
self.assertFalse(utils.isServerName(''))
self.assertTrue(utils.isServerName('pylink.overdrive.pw'))
self.assertFalse(utils.isServerName(' i lost the game'))
self.assertFalse(utils.isServerName(' i lost th.e game'))
def testJoinModes(self):
res = utils.joinModes({('l', '50'), ('n', None), ('t', None)})

View File

@ -82,8 +82,7 @@ def _isASCII(s):
return all(char in chars for char in s)
def isServerName(s):
return _isASCII(s) and '.' in s and not s.startswith('.') \
and not s.endswith('.')
return _isASCII(s) and '.' in s and not s.startswith('.')
def parseModes(irc, target, args):
"""Parses a mode string into a list of (mode, argument) tuples.