Fix banmask creation. Thanks Progval for the patch!

fixes https://sourceforge.net/tracker/?func=detail&aid=3088559&group_id=58965&atid=489447

incorporating patch https://sourceforge.net/tracker/?func=detail&aid=3163843&group_id=58965&atid=489449

Signed-off-by: James McCoy <jamessan@users.sourceforge.net>
This commit is contained in:
Daniel Folkinshteyn 2011-01-24 16:09:18 -05:00 committed by James McCoy
parent df5391dcf7
commit 8f7c4bdf7f
2 changed files with 5 additions and 1 deletions

View File

@ -200,7 +200,7 @@ def banmask(hostmask):
L[-1] = '*'
return '*!*@' + ':'.join(L)
else:
if '.' in host:
if len(host.split('.')) > 2: # If it is a subdomain
return '*!*@*%s' % host[host.find('.'):]
else:
return '*!*@' + host

View File

@ -214,6 +214,10 @@ class FunctionsTestCase(SupyTestCase):
msg.prefix),
'%r didn\'t match %r' % (msg.prefix, banmask))
self.assertEqual(ircutils.banmask('foobar!user@host'), '*!*@host')
self.assertEqual(ircutils.banmask('foobar!user@host.tld'),
'*!*@host.tld')
self.assertEqual(ircutils.banmask('foobar!user@sub.host.tld'),
'*!*@*.host.tld')
self.assertEqual(ircutils.banmask('foo!bar@2001::'), '*!*@2001::*')
def testSeparateModes(self):