Fix the command module handling of non-ascii values.

We can't depend on the args being unicode text because we're in module
land, not in the ansible controller land
This commit is contained in:
Toshio Kuratomi 2015-03-25 13:57:48 -07:00
parent 38892e986e
commit 60f972dfe4

View file

@ -1433,7 +1433,7 @@ class AnsibleModule(object):
msg = None msg = None
st_in = None st_in = None
# Set a temporart env path if a prefix is passed # Set a temporary env path if a prefix is passed
env=os.environ env=os.environ
if path_prefix: if path_prefix:
env['PATH']="%s:%s" % (path_prefix, env['PATH']) env['PATH']="%s:%s" % (path_prefix, env['PATH'])
@ -1442,7 +1442,12 @@ class AnsibleModule(object):
# in reporting later, which strips out things like # in reporting later, which strips out things like
# passwords from the args list # passwords from the args list
if isinstance(args, basestring): if isinstance(args, basestring):
to_clean_args = shlex.split(args.encode('utf-8')) if isinstance(args, unicode):
b_args = args.encode('utf-8')
else:
b_args = args
to_clean_args = shlex.split(b_args)
del b_args
else: else:
to_clean_args = args to_clean_args = args