mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-10 20:22:36 +01:00
Aka: Prevent overriding of other plugins commands.
This commit is contained in:
parent
10d9c43ab8
commit
fba38a5df9
@ -242,6 +242,12 @@ class Aka(callbacks.Plugin):
|
||||
def isCommandMethod(self, name):
|
||||
if sys.version_info[0] < 3 and isinstance(name, str):
|
||||
name = name.decode('utf8')
|
||||
args = name.split(' ')
|
||||
if len(args) > 1 and \
|
||||
callbacks.canonicalName(args[0]) != self.canonicalName():
|
||||
for cb in dynamic.irc.callbacks: # including this plugin
|
||||
if cb.getCommand(args[0:-1]):
|
||||
return False
|
||||
channel = dynamic.channel or 'global'
|
||||
return self._db.has_aka(channel, name) or \
|
||||
self._db.has_aka('global', name) or \
|
||||
|
@ -151,8 +151,19 @@ class AkaChannelTestCase(ChannelPluginTestCase):
|
||||
self.assertNotError('aka add "foo bar" "echo spam"')
|
||||
self.assertResponse('foo bar', 'spam')
|
||||
self.assertNotError('aka add "foo" "echo egg"')
|
||||
self.assertResponse('foo bar', 'spam')
|
||||
self.assertResponse('foo', 'egg')
|
||||
# You could expect 'spam' here, but in fact, this is dangerous.
|
||||
# Just imagine this session:
|
||||
# <evil_user> aka add "echo foo" quit
|
||||
# <bot> The operation succeeded.
|
||||
# ...
|
||||
# <owner> echo foo
|
||||
# * bot has quit
|
||||
self.assertResponse('foo bar', 'egg')
|
||||
|
||||
def testNoOverride(self):
|
||||
self.assertNotError('aka add "echo foo" "echo bar"')
|
||||
self.assertResponse('echo foo', 'foo')
|
||||
|
||||
def testRecursivity(self):
|
||||
self.assertNotError('aka add fact '
|
||||
|
Loading…
Reference in New Issue
Block a user