Fixes #4958 Truncate printed stdout if it contains non-printable characters

pull/5586/head
James Tanner 11 years ago
parent 78ec7c736f
commit d7c8cf6ca7

@ -38,6 +38,7 @@ import ansible.inventory
from ansible import utils
from ansible.utils import template
from ansible.utils import check_conditional
from ansible.utils import string_functions
from ansible import errors
from ansible import module_common
import poller
@ -742,6 +743,12 @@ class Runner(object):
self.callbacks.on_unreachable(host, result.result)
else:
data = result.result
# https://github.com/ansible/ansible/issues/4958
if "stdout" in data and sys.stdout.isatty():
if not string_functions.isprintable(data['stdout']):
data['stdout'] = ''
if 'item' in inject:
result.result['item'] = inject['item']

@ -0,0 +1,7 @@
def isprintable(instring):
#http://stackoverflow.com/a/3637294
import string
printset = set(string.printable)
isprintable = set(instring).issubset(printset)
return isprintable
Loading…
Cancel
Save