mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 11:12:47 +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')
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user