mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
Aka: Prevent infinite loop (+ memory bomb) when nesting Akas using $*.
This commit is contained in:
parent
f8bfb03dee
commit
23dfa23f31
@ -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)
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user