Make sure the ban length is an integer

This commit is contained in:
James Vega 2003-12-12 16:56:25 +00:00
parent 42ce8c33a6
commit e485984604
2 changed files with 6 additions and 1 deletions

View File

@ -183,7 +183,11 @@ class Channel(callbacks.Privmsg):
self.log.warning('%r tried to make me kban myself.', msg.prefix)
irc.error(msg, 'I cowardly refuse to kickban myself.')
return
length = int(length or 0)
try:
length = int(length or 0)
except ValueError:
irc.error(msg, 'Ban length must be a valid integer.')
return
try:
bannedHostmask = irc.state.nickToHostmask(bannedNick)
except KeyError:

View File

@ -96,6 +96,7 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation):
m = self.getMsg(' ')
self.assertEqual(m, ircmsgs.kick(self.channel, 'foobar', self.nick))
self.assertNotRegexp('kban adlkfajsdlfkjsd', 'KeyError')
self.assertNotRegexp('kban foobar time', 'ValueError')
self.assertError('kban %s' % self.nick)
def testLobotomizers(self):