Also clean template data even if marked unsafe

Fixes #20568

(cherry picked from commit 86beb55a90)
pull/21709/head
James Cammarata 8 years ago
parent 68dbed2a5e
commit ad7c55dd9d

@ -274,7 +274,7 @@ class Templar:
def _clean_data(self, orig_data): def _clean_data(self, orig_data):
''' remove jinja2 template tags from a string ''' ''' remove jinja2 template tags from a string '''
if not isinstance(orig_data, string_types) or hasattr(orig_data, '__UNSAFE__'): if not isinstance(orig_data, string_types):
return orig_data return orig_data
with contextlib.closing(StringIO(orig_data)) as data: with contextlib.closing(StringIO(orig_data)) as data:
@ -383,6 +383,7 @@ class Templar:
overrides=overrides, overrides=overrides,
disable_lookups=disable_lookups, disable_lookups=disable_lookups,
) )
unsafe = hasattr(result, '__UNSAFE__') unsafe = hasattr(result, '__UNSAFE__')
if convert_data and not self._no_type_regex.match(variable): if convert_data and not self._no_type_regex.match(variable):
# if this looks like a dictionary or list, convert it to such using the safe_eval method # if this looks like a dictionary or list, convert it to such using the safe_eval method

Loading…
Cancel
Save