1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Handle UTF-8 in templates

This is required to run commands containing non-ASCII characters, e.g.:

ansible localhost -m shell -a 'echo ą'
This commit is contained in:
Grzegorz Nosek 2012-08-20 21:00:31 +02:00 committed by Michael DeHaan
parent 4121109665
commit 2aef0335cb

View file

@ -215,6 +215,10 @@ def template(text, vars):
''' run a text buffer through the templating engine until it no longer changes ''' ''' run a text buffer through the templating engine until it no longer changes '''
prev_text = '' prev_text = ''
try:
text = text.decode('utf-8')
except UnicodeEncodeError:
pass # already unicode
depth = 0 depth = 0
while prev_text != text: while prev_text != text:
depth = depth + 1 depth = depth + 1