Removed recursive alias detection; it was imperfect and our nesting limit will catch issues now.

This commit is contained in:
Jeremy Fincher 2005-02-04 02:35:39 +00:00
parent 14837bc544
commit a656fd0693
3 changed files with 1 additions and 34 deletions

View File

@ -49,7 +49,7 @@ import plugin
reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well!
from plugin import findBiggestDollar, AliasError, findAliasCommand # tests
from plugin import findBiggestDollar, AliasError # for the tests.
if world.testing:
import test

View File

@ -79,11 +79,6 @@ class AliasError(Exception):
class RecursiveAlias(AliasError):
pass
def findAliasCommand(s, alias):
s = re.escape(s)
r = re.compile(r'(?:(^|\[)\s*\b%s\b|\|\s*\b%s\b)' % (s, s))
return bool(r.search(alias))
dollarRe = re.compile(r'\$(\d+)')
def findBiggestDollar(alias):
dollars = dollarRe.findall(alias)
@ -106,8 +101,6 @@ def findBiggestAt(alias):
def makeNewAlias(name, alias):
original = alias
if findAliasCommand(name, alias):
raise RecursiveAlias
biggestDollar = findBiggestDollar(original)
biggestAt = findBiggestAt(original)
wildcard = '$*' in original

View File

@ -34,21 +34,6 @@ import supybot.plugin as plugin
Alias = plugin.loadPluginModule('Alias')
class FunctionsTest(SupyTestCase):
def testFindAliasCommand(self):
s = 'command'
self.failIf(Alias.findAliasCommand(s, ''))
self.failIf(Alias.findAliasCommand(s, 'foo'))
self.failIf(Alias.findAliasCommand(s, 'foo bar [ baz]'))
self.failIf(Alias.findAliasCommand(s, 'foo bar [baz]'))
self.failUnless(Alias.findAliasCommand(s, s))
self.failUnless(Alias.findAliasCommand(s, ' %s' % s))
self.failUnless(Alias.findAliasCommand(s, '[%s]' % s))
self.failUnless(Alias.findAliasCommand(s, '[ %s]' % s))
self.failUnless(Alias.findAliasCommand(s, 'foo bar [%s]' % s))
self.failUnless(Alias.findAliasCommand(s, 'foo bar [ %s]' % s))
self.failUnless(Alias.findAliasCommand(s, 'foo | %s' % s))
self.failUnless(Alias.findAliasCommand(s, 'foo |%s' % s))
def testFindBiggestDollar(self):
self.assertEqual(Alias.findBiggestDollar(''), 0)
self.assertEqual(Alias.findBiggestDollar('foo'), 0)
@ -100,17 +85,6 @@ class AliasTestCase(ChannelPluginTestCase):
self.assertResponse('swap 1 2 3 4 5', '2 1 3 4 5')
self.assertError('alias add foo "echo $1 @1 $*"')
def testNoRecursion(self):
self.assertError('alias add rotinfinity "rot13 [rotinfinity $1]"')
self.assertNotError('alias add rotinfintynot "rot13 [rotinfinity $1]"')
self.assertNotError('alias add rotinfin "rot13 [rotinfinity $1]"')
def testNonCanonicalName(self):
self.assertError('alias add FOO foo')
self.assertError('alias add [] foo')
self.assertError('alias add "foo bar" foo')
self.assertError('alias add "foo|bar" foo')
def testChannel(self):
self.assertNotError('alias add channel echo $channel')
self.assertResponse('alias channel', self.channel)