mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-18 14:40:51 +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))
|
replace(tokens, lambda s: atRe.sub(regexpReplace, s))
|
||||||
if wildcard:
|
if wildcard:
|
||||||
def everythingReplace(tokens):
|
def everythingReplace(tokens):
|
||||||
|
new_tokens = []
|
||||||
for (i, token) in enumerate(tokens):
|
for (i, token) in enumerate(tokens):
|
||||||
if isinstance(token, list):
|
if isinstance(token, list):
|
||||||
if everythingReplace(token):
|
if everythingReplace(token):
|
||||||
return
|
return
|
||||||
if token == '$*':
|
if token == '$*':
|
||||||
tokens[i:i+1] = args
|
new_tokens.extend(args)
|
||||||
elif '$*' in token:
|
else:
|
||||||
tokens[i] = token.replace('$*', ' '.join(args))
|
new_tokens.append(
|
||||||
|
token.replace('$*', ' '.join(args)))
|
||||||
|
tokens[:] = new_tokens
|
||||||
return False
|
return False
|
||||||
everythingReplace(tokens)
|
everythingReplace(tokens)
|
||||||
self.Proxy(irc, msg, tokens)
|
self.Proxy(irc, msg, tokens)
|
||||||
|
@ -157,6 +157,10 @@ class AkaChannelTestCase(ChannelPluginTestCase):
|
|||||||
self.assertResponse('fact 4', '24')
|
self.assertResponse('fact 4', '24')
|
||||||
self.assertRegexp('fact 50', 'more nesting')
|
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):
|
class AkaTestCase(PluginTestCase):
|
||||||
plugins = ('Aka', 'Alias', 'User', 'Utilities')
|
plugins = ('Aka', 'Alias', 'User', 'Utilities')
|
||||||
|
|
||||||
@ -198,6 +202,4 @@ class AkaTestCase(PluginTestCase):
|
|||||||
self.assertResponse('aka spam', 'egg')
|
self.assertResponse('aka spam', 'egg')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user