mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-05-06 22:57:30 +02:00
Math.rpn should use _mathSafeEnv, otherwise untrusted users can freeze the bot
This commit is contained in:
parent
943c8bc495
commit
1aeb847509
@ -279,8 +279,8 @@ class Math(callbacks.Plugin):
|
|||||||
x = abs(x)
|
x = abs(x)
|
||||||
stack.append(x)
|
stack.append(x)
|
||||||
except ValueError: # Not a float.
|
except ValueError: # Not a float.
|
||||||
if arg in self._mathEnv:
|
if arg in self._mathSafeEnv:
|
||||||
f = self._mathEnv[arg]
|
f = self._mathSafeEnv[arg]
|
||||||
if callable(f):
|
if callable(f):
|
||||||
called = False
|
called = False
|
||||||
arguments = []
|
arguments = []
|
||||||
@ -303,7 +303,7 @@ class Math(callbacks.Plugin):
|
|||||||
arg1 = stack.pop()
|
arg1 = stack.pop()
|
||||||
s = '%s%s%s' % (arg1, arg, arg2)
|
s = '%s%s%s' % (arg1, arg, arg2)
|
||||||
try:
|
try:
|
||||||
stack.append(eval(s, self._mathEnv, self._mathEnv))
|
stack.append(eval(s, self._mathSafeEnv, self._mathSafeEnv))
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
irc.error(format(_('%q is not a defined function.'),
|
irc.error(format(_('%q is not a defined function.'),
|
||||||
arg))
|
arg))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user