From 9aede17efdfbfc22cdddb50883eaa26b42db3f95 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sun, 18 Jan 2004 19:35:36 +0000 Subject: [PATCH] Changed not even to define eval/exec when conf.allowEval is False. --- src/Owner.py | 58 +++++++++++++++++++++++++++------------------------- test/test.py | 1 + 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/Owner.py b/src/Owner.py index 8f37ee956..f56b419fa 100644 --- a/src/Owner.py +++ b/src/Owner.py @@ -110,7 +110,8 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg): _srcPlugins = ('Owner', 'Misc', 'Admin', 'User', 'Channel') def __init__(self): callbacks.Privmsg.__init__(self) - setattr(self.__class__, 'exec', self.__class__._exec) + if hasattr(self.__class__, '_exec'): + setattr(self.__class__, 'exec', self.__class__._exec) self.defaultPlugins = {'list': 'Misc', 'capabilities': 'User', 'addcapability': 'Admin', @@ -242,36 +243,37 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg): return irc.replySuccess() - def eval(self, irc, msg, args): - """ + if conf.allowEval: + def eval(self, irc, msg, args): + """ - Evaluates and returns its value. - """ - if conf.allowEval: - s = privmsgs.getArgs(args) - try: - irc.reply(repr(eval(s))) - except SyntaxError, e: - irc.reply('%s: %r' % (utils.exnToString(e), s)) - except Exception, e: - irc.reply(utils.exnToString(e)) - else: - irc.error('You must enable conf.allowEval for that to work.') + Evaluates and returns its value. + """ + if conf.allowEval: + s = privmsgs.getArgs(args) + try: + irc.reply(repr(eval(s))) + except SyntaxError, e: + irc.reply('%s: %r' % (utils.exnToString(e), s)) + except Exception, e: + irc.reply(utils.exnToString(e)) + else: + irc.error('You must enable conf.allowEval for that to work.') - def _exec(self, irc, msg, args): - """ + def _exec(self, irc, msg, args): + """ - Execs . Returns success if it didn't raise any exceptions. - """ - if conf.allowEval: - s = privmsgs.getArgs(args) - try: - exec s - irc.replySuccess() - except Exception, e: - irc.reply(utils.exnToString(e)) - else: - irc.error('You must enable conf.allowEval for that to work.') + Execs . Returns success if it didn't raise any exceptions. + """ + if conf.allowEval: + s = privmsgs.getArgs(args) + try: + exec s + irc.replySuccess() + except Exception, e: + irc.reply(utils.exnToString(e)) + else: + irc.error('You must enable conf.allowEval for that to work.') def ircquote(self, irc, msg, args): """ diff --git a/test/test.py b/test/test.py index 17bd45756..93c0a0f52 100755 --- a/test/test.py +++ b/test/test.py @@ -53,6 +53,7 @@ registry.open(registryFilename) import log import conf +conf.allowEval = True import fix