Prevent the 'hostmask' converter from returning '*!*@*' while 'foo!*@*' was given.

This commit is contained in:
Valentin Lorentz 2011-12-27 11:55:50 +01:00
parent 95a9ffac17
commit fc3d3e6c01
2 changed files with 14 additions and 3 deletions

View File

@ -205,11 +205,19 @@ class ChannelTestCase(ChannelPluginTestCase):
def testIgnore(self):
orig = conf.supybot.protocols.irc.banmask()
def ignore(given, expect=None):
if expect is None:
expect = given
self.assertNotError('channel ignore add %s' % given)
self.assertResponse('channel ignore list', "'%s'" % expect)
self.assertNotError('channel ignore remove %s' % expect)
self.assertRegexp('channel ignore list', 'not currently')
try:
ignore('foo!bar@baz', '*!bar@baz')
ignore('foo!*@*')
conf.supybot.protocols.irc.banmask.setValue(['exact'])
self.assertNotError('channel ignore add foo!bar@baz')
self.assertResponse('channel ignore list', "'foo!bar@baz'")
self.assertNotError('channel ignore remove foo!bar@baz')
ignore('foo!bar@baz')
ignore('foo!*@*')
self.assertError('ban add not!a.hostmask')
finally:
conf.supybot.protocols.irc.banmask.setValue(orig)

View File

@ -988,6 +988,9 @@ class Banmask(registry.SpaceSeparatedSetOfStrings):
bhost = host
elif option == 'exact':
return hostmask
if (bnick, buser, bhost) == ('*', '*', '*') and \
ircutils.isUserHostmask(hostmask):
return hostmask
return ircutils.joinHostmask(bnick, buser, bhost)
registerChannelValue(supybot.protocols.irc, 'banmask',