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

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

This commit is contained in:
James Tanner 2014-01-10 15:08:45 -05:00
parent 78ec7c736f
commit d7c8cf6ca7
2 changed files with 14 additions and 0 deletions

View file

@ -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']

View file

@ -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