diff options
Diffstat (limited to 'ipapython')
-rw-r--r-- | ipapython/ipautil.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 240e0d872..47b651c1d 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -68,7 +68,15 @@ def realm_to_suffix(realm_name): return ",".join(terms) def template_str(txt, vars): - return string.Template(txt).substitute(vars) + val = string.Template(txt).substitute(vars) + + # eval() is a special string one can insert into a template to have the + # Python interpreter evaluate the string. This is intended to allow + # math to be performed in templates. + pattern = re.compile('(eval\s*\(([^()]*)\))') + val = pattern.sub(lambda x: str(eval(x.group(2))), val) + + return val def template_file(infilename, vars): txt = open(infilename).read() |