mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-22 10:04:25 +01:00
Channel: Prevent @iban from adding wildcard when an exact banmask is given.
This commit is contained in:
parent
22febc4a20
commit
650cbe548a
@ -339,11 +339,13 @@ class Channel(callbacks.Plugin):
|
||||
bannedNick = target
|
||||
try:
|
||||
bannedHostmask = irc.state.nickToHostmask(target)
|
||||
banmaskstyle = conf.supybot.protocols.irc.banmask
|
||||
banmask = banmaskstyle.makeBanmask(bannedHostmask, [o[0] for o in optlist])
|
||||
except KeyError:
|
||||
irc.error(format(_('I haven\'t seen %s.'), bannedNick), Raise=True)
|
||||
else:
|
||||
bannedNick = ircutils.nickFromHostmask(target)
|
||||
bannedHostmask = target
|
||||
banmask = bannedHostmask = target
|
||||
if not irc.isNick(bannedNick):
|
||||
self.log.warning('%q tried to kban a non nick: %q',
|
||||
msg.prefix, bannedNick)
|
||||
@ -355,8 +357,6 @@ class Channel(callbacks.Plugin):
|
||||
if not reason:
|
||||
reason = msg.nick
|
||||
capability = ircdb.makeChannelCapability(channel, 'op')
|
||||
banmaskstyle = conf.supybot.protocols.irc.banmask
|
||||
banmask = banmaskstyle.makeBanmask(bannedHostmask, [o[0] for o in optlist])
|
||||
# Check (again) that they're not trying to make us kickban ourself.
|
||||
if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
|
||||
if ircutils.hostmaskPatternEqual(bannedHostmask, irc.prefix):
|
||||
|
@ -156,11 +156,22 @@ class ChannelTestCase(ChannelPluginTestCase):
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+v', 'bar'))
|
||||
|
||||
def assertBan(self, query, hostmask, **kwargs):
|
||||
def assertKban(self, query, hostmask, **kwargs):
|
||||
m = self.getMsg(query, **kwargs)
|
||||
self.assertEqual(m, ircmsgs.ban(self.channel, hostmask))
|
||||
m = self.getMsg(' ')
|
||||
self.assertEqual(m.command, 'KICK')
|
||||
def assertBan(self, query, hostmask, **kwargs):
|
||||
m = self.getMsg(query, **kwargs)
|
||||
self.assertEqual(m, ircmsgs.ban(self.channel, hostmask))
|
||||
|
||||
def testIban(self):
|
||||
self.irc.feedMsg(ircmsgs.join(self.channel,
|
||||
prefix='foobar!user@host.domain.tld'))
|
||||
self.assertError('iban foo!bar@baz')
|
||||
self.irc.feedMsg(ircmsgs.op(self.channel, self.irc.nick))
|
||||
self.assertBan('iban foo!bar@baz', 'foo!bar@baz')
|
||||
self.assertBan('iban foobar', 'foobar!user@host.domain.tld')
|
||||
|
||||
## def testKban(self):
|
||||
## self.irc.prefix = 'something!else@somehwere.else'
|
||||
@ -170,16 +181,16 @@ class ChannelTestCase(ChannelPluginTestCase):
|
||||
## self.assertError('kban foobar')
|
||||
## self.irc.feedMsg(ircmsgs.op(self.channel, self.irc.nick))
|
||||
## self.assertError('kban foobar -1')
|
||||
## self.assertBan('kban foobar', '*!*@*.domain.tld')
|
||||
## self.assertBan('kban --exact foobar', 'foobar!user@host.domain.tld')
|
||||
## self.assertBan('kban --host foobar', '*!*@host.domain.tld')
|
||||
## self.assertBan('kban --user foobar', '*!user@*')
|
||||
## self.assertBan('kban --nick foobar', 'foobar!*@*')
|
||||
## self.assertBan('kban --nick --user foobar', 'foobar!user@*')
|
||||
## self.assertBan('kban --nick --host foobar',
|
||||
## self.assertKban('kban foobar', '*!*@*.domain.tld')
|
||||
## self.assertKban('kban --exact foobar', 'foobar!user@host.domain.tld')
|
||||
## self.assertKban('kban --host foobar', '*!*@host.domain.tld')
|
||||
## self.assertKban('kban --user foobar', '*!user@*')
|
||||
## self.assertKban('kban --nick foobar', 'foobar!*@*')
|
||||
## self.assertKban('kban --nick --user foobar', 'foobar!user@*')
|
||||
## self.assertKban('kban --nick --host foobar',
|
||||
## 'foobar!*@host.domain.tld')
|
||||
## self.assertBan('kban --user --host foobar', '*!user@host.domain.tld')
|
||||
## self.assertBan('kban --nick --user --host foobar',
|
||||
## self.assertKban('kban --user --host foobar', '*!user@host.domain.tld')
|
||||
## self.assertKban('kban --nick --user --host foobar',
|
||||
## 'foobar!user@host.domain.tld')
|
||||
## self.assertNotRegexp('kban adlkfajsdlfkjsd', 'KeyError')
|
||||
## self.assertNotRegexp('kban foobar time', 'ValueError')
|
||||
|
Loading…
Reference in New Issue
Block a user