Fixed bug in banmask when the host doesn't have a dot in it (rare, but possible).

This commit is contained in:
Jeremy Fincher 2003-11-13 19:00:35 +00:00
parent 7b86dfb195
commit 6004181695
2 changed files with 7 additions and 3 deletions

View File

@ -151,9 +151,12 @@ def banmask(hostmask):
assert isUserHostmask(hostmask)
host = hostFromHostmask(hostmask)
if isIP(host):
return ('*!*@%s.*' % host[:host.rfind('.')])
return '*!*@%s.*' % host[:host.rfind('.')]
else:
return ('*!*@*%s' % host[host.find('.'):])
if '.' in host:
return '*!*@*%s' % host[host.find('.'):]
else:
return '*!*@' + host
_argModes = 'ovhblkqe'
def separateModes(args):

View File

@ -125,12 +125,13 @@ class FunctionsTestCase(unittest.TestCase):
self.failIf(ircutils.isNick('8foo'))
self.failIf(ircutils.isNick('10'))
def banmask(self):
def testBanmask(self):
for msg in msgs:
if ircutils.isUserHostmask(msg.prefix):
self.failUnless(ircutils.hostmaskPatternEqual
(ircutils.banmask(msg.prefix),
msg.prefix))
self.assertEqual(ircutils.banmask('foobar!user@host'), '*!*@host')
def testSeparateModes(self):
self.assertEqual(ircutils.separateModes(['+ooo', 'x', 'y', 'z']),