Aka: Remove side effects in everythingReplace and fix crash when evaluating expressions where $* is in the nested command.

This commit is contained in:
Valentin Lorentz 2013-08-11 12:02:00 +02:00
parent 269f22a84b
commit d6223eee9d
2 changed files with 13 additions and 5 deletions

View File

@ -298,19 +298,23 @@ class Aka(callbacks.Plugin):
replace(tokens, lambda s: atRe.sub(regexpReplace, s))
if wildcard:
def everythingReplace(tokens):
ret = False
new_tokens = []
for (i, token) in enumerate(tokens):
if isinstance(token, list):
if everythingReplace(token):
return
(sub_ret, sub_tokens) = everythingReplace(token)
new_tokens.append(sub_tokens)
if sub_ret:
continue
if token == '$*':
new_tokens.extend(args)
ret = True
else:
new_tokens.append(
token.replace('$*', ' '.join(args)))
tokens[:] = new_tokens
return False
everythingReplace(tokens)
ret = True
return (ret, new_tokens)
(ret, tokens) = everythingReplace(tokens)
self.Proxy(irc, msg, tokens)
if biggestDollar and (wildcard or biggestAt):
flexargs = _(' at least')

View File

@ -96,6 +96,10 @@ class AkaChannelTestCase(ChannelPluginTestCase):
self.assertError('moo')
self.assertResponse('moo foo', 'foo')
self.assertResponse('moo foo bar', 'foo bar')
self.assertNotError('aka add spam "echo [echo $*]"')
self.assertResponse('spam egg', 'egg')
self.assertResponse('spam egg bacon', 'egg bacon')
def testChannel(self):
self.assertNotError('aka add channel echo $channel')