Prevent template changing options (#20775)

* Prevent complex template validation changing input value

* Remove deprecation warnings
This commit is contained in:
Paulus Schoutsen 2019-02-06 11:15:27 -08:00 committed by GitHub
parent e6cd04d711
commit 59393ab085
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 8 deletions

View file

@ -436,13 +436,15 @@ def template(value):
def template_complex(value):
"""Validate a complex jinja2 template."""
if isinstance(value, list):
for idx, element in enumerate(value):
value[idx] = template_complex(element)
return value
return_value = value.copy()
for idx, element in enumerate(return_value):
return_value[idx] = template_complex(element)
return return_value
if isinstance(value, dict):
for key, element in value.items():
value[key] = template_complex(element)
return value
return_value = value.copy()
for key, element in return_value.items():
return_value[key] = template_complex(element)
return return_value
return template(value)