Don't allow __ or builtins in env dictionarys for ImageMath.eval

This commit is contained in:
Eric Soroos 2023-10-27 11:21:18 +02:00 committed by Andrew Murray
parent c3af2643dd
commit 45c726fd4d

View File

@ -237,6 +237,10 @@ def eval(expression, _dict={}, **kw):
args.update(_dict)
args.update(kw)
for k, v in args.items():
if '__' in k or hasattr(__builtins__, k):
msg = f"'{k}' not allowed"
raise ValueError(msg)
if hasattr(v, "im"):
args[k] = _Operand(v)