mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 14:59:34 +01:00
Added some more error-checking to the addAlias method.
This commit is contained in:
parent
1099ca0705
commit
28fb603ca0
@ -185,7 +185,10 @@ class Alias(callbacks.Privmsg):
|
|||||||
irc.error(msg, 'There is no such alias.')
|
irc.error(msg, 'There is no such alias.')
|
||||||
unfreeze = privmsgs.checkCapability(unfreeze, 'admin')
|
unfreeze = privmsgs.checkCapability(unfreeze, 'admin')
|
||||||
|
|
||||||
|
_invalidCharsRe = re.compile(r'[\[\]\s]')
|
||||||
def addAlias(self, irc, name, alias, freeze=False):
|
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)
|
realName = callbacks.canonicalName(name)
|
||||||
if name != realName:
|
if name != realName:
|
||||||
raise AliasError,'That name isn\'t valid. Try %r instead'%realName
|
raise AliasError,'That name isn\'t valid. Try %r instead'%realName
|
||||||
|
@ -96,6 +96,8 @@ class AliasTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
|
|
||||||
def testNonCanonicalName(self):
|
def testNonCanonicalName(self):
|
||||||
self.assertError('alias FOO foo')
|
self.assertError('alias FOO foo')
|
||||||
|
self.assertError('alias [] foo')
|
||||||
|
self.assertError('alias "foo bar" foo')
|
||||||
|
|
||||||
def testNotCannotNestRaised(self):
|
def testNotCannotNestRaised(self):
|
||||||
self.assertNotError('alias mytell "tell $channel $1"')
|
self.assertNotError('alias mytell "tell $channel $1"')
|
||||||
|
Loading…
Reference in New Issue
Block a user