mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
fix unicode pillar values #3436
This commit is contained in:
parent
3fdb52d1bf
commit
53285f7781
1 changed files with 15 additions and 7 deletions
|
@ -290,6 +290,20 @@ def _get_jinja_error(trace, context=None):
|
|||
return line, out
|
||||
|
||||
|
||||
def _decode_recursively(object_):
|
||||
if isinstance(object_, list):
|
||||
return [_decode_recursively(o) for o in object_]
|
||||
if isinstance(object_, tuple):
|
||||
return tuple([_decode_recursively(o) for o in object_])
|
||||
if isinstance(object_, dict):
|
||||
return dict([(_decode_recursively(key), _decode_recursively(value))
|
||||
for key, value in six.iteritems(object_)])
|
||||
elif isinstance(object_, string_types):
|
||||
return salt.utils.locales.sdecode(object_)
|
||||
else:
|
||||
return object_
|
||||
|
||||
|
||||
def render_jinja_tmpl(tmplstr, context, tmplpath=None):
|
||||
opts = context['opts']
|
||||
saltenv = context['saltenv']
|
||||
|
@ -354,13 +368,7 @@ def render_jinja_tmpl(tmplstr, context, tmplpath=None):
|
|||
|
||||
jinja_env.tests['list'] = salt.utils.is_list
|
||||
|
||||
decoded_context = {}
|
||||
for key, value in six.iteritems(context):
|
||||
if not isinstance(value, string_types):
|
||||
decoded_context[key] = value
|
||||
continue
|
||||
|
||||
decoded_context[key] = salt.utils.locales.sdecode(value)
|
||||
decoded_context = _decode_recursively(context)
|
||||
|
||||
try:
|
||||
template = jinja_env.from_string(tmplstr)
|
||||
|
|
Loading…
Add table
Reference in a new issue