mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Aka: Remove side effects in everythingReplace and fix crash when evaluating expressions where $* is in the nested command.
This commit is contained in:
parent
269f22a84b
commit
d6223eee9d
@ -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')
|
||||
|
@ -97,6 +97,10 @@ class AkaChannelTestCase(ChannelPluginTestCase):
|
||||
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')
|
||||
self.assertResponse('aka channel', self.channel)
|
||||
|
Loading…
Reference in New Issue
Block a user