Added some more error-checking to the addAlias method.

This commit is contained in:
Jeremy Fincher 2003-10-07 22:19:08 +00:00
parent 1099ca0705
commit 28fb603ca0
2 changed files with 5 additions and 0 deletions

View File

@ -185,7 +185,10 @@ class Alias(callbacks.Privmsg):
irc.error(msg, 'There is no such alias.')
unfreeze = privmsgs.checkCapability(unfreeze, 'admin')
_invalidCharsRe = re.compile(r'[\[\]\s]')
def addAlias(self, irc, name, alias, freeze=False):
if self._invalidCharsRe.search(name):
raise AliasError, 'Names cannot contain spaces or square brackets.'
realName = callbacks.canonicalName(name)
if name != realName:
raise AliasError,'That name isn\'t valid. Try %r instead'%realName

View File

@ -96,6 +96,8 @@ class AliasTestCase(PluginTestCase, PluginDocumentation):
def testNonCanonicalName(self):
self.assertError('alias FOO foo')
self.assertError('alias [] foo')
self.assertError('alias "foo bar" foo')
def testNotCannotNestRaised(self):
self.assertNotError('alias mytell "tell $channel $1"')