Aka: Prevent infinite loop (+ memory bomb) when nesting Akas using $*.

This commit is contained in:
Valentin Lorentz 2013-08-08 14:11:44 +02:00
parent f8bfb03dee
commit 23dfa23f31
2 changed files with 10 additions and 5 deletions

View File

@ -298,14 +298,17 @@ class Aka(callbacks.Plugin):
replace(tokens, lambda s: atRe.sub(regexpReplace, s))
if wildcard:
def everythingReplace(tokens):
new_tokens = []
for (i, token) in enumerate(tokens):
if isinstance(token, list):
if everythingReplace(token):
return
if token == '$*':
tokens[i:i+1] = args
elif '$*' in token:
tokens[i] = token.replace('$*', ' '.join(args))
new_tokens.extend(args)
else:
new_tokens.append(
token.replace('$*', ' '.join(args)))
tokens[:] = new_tokens
return False
everythingReplace(tokens)
self.Proxy(irc, msg, tokens)

View File

@ -157,6 +157,10 @@ class AkaChannelTestCase(ChannelPluginTestCase):
self.assertResponse('fact 4', '24')
self.assertRegexp('fact 50', 'more nesting')
def testDollarStarNesting(self):
self.assertNotError('aka add alias aka $*')
self.assertNotError('alias add a+ aka add $*')
class AkaTestCase(PluginTestCase):
plugins = ('Aka', 'Alias', 'User', 'Utilities')
@ -198,6 +202,4 @@ class AkaTestCase(PluginTestCase):
self.assertResponse('aka spam', 'egg')
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: