diff --git a/src/ircutils.py b/src/ircutils.py index c7b5408df..b2ec6bd2d 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -196,7 +196,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 diff --git a/test/test_ircutils.py b/test/test_ircutils.py index 6dc11e21d..b0fca5261 100644 --- a/test/test_ircutils.py +++ b/test/test_ircutils.py @@ -233,6 +233,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):