mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Mcsalgado's change to use shlex.quote instead of pipes.quote (#18534)
* Replace pipes.quote for shlex_quote * More migration of pipes.quote to shlex_quote Note that we cannot yet move module code over. Modules have six-1.4 bundled which does not have shlex_quote. This shouldn't be a problem as the function is still importable from pipes.quote. It's just that this has become an implementation detail that makes us want to import from shlex instead. Once we get rid of the python2.4 dependency we can update to a newer version of bundled six module-side and then we're free to use shlex_quote everywhere.
This commit is contained in:
@@ -22,7 +22,6 @@ __metaclass__ = type
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import pipes
|
||||
import random
|
||||
import re
|
||||
import stat
|
||||
@@ -30,9 +29,9 @@ import tempfile
|
||||
import time
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
from ansible.compat.six import binary_type, text_type, iteritems, with_metaclass
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible.compat.six import binary_type, text_type, iteritems, with_metaclass
|
||||
from ansible.compat.six.moves import shlex_quote
|
||||
from ansible.errors import AnsibleError, AnsibleConnectionFailure
|
||||
from ansible.executor.module_common import modify_module
|
||||
from ansible.module_utils._text import to_bytes, to_native, to_text
|
||||
@@ -596,7 +595,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
||||
# the remote system, which can be read and parsed by the module
|
||||
args_data = ""
|
||||
for k,v in iteritems(module_args):
|
||||
args_data += '%s=%s ' % (k, pipes.quote(text_type(v)))
|
||||
args_data += '%s=%s ' % (k, shlex_quote(text_type(v)))
|
||||
self._transfer_data(args_file_path, args_data)
|
||||
elif module_style in ('non_native_want_json', 'binary'):
|
||||
self._transfer_data(args_file_path, json.dumps(module_args))
|
||||
@@ -748,7 +747,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
||||
# only applied for the default executable to avoid interfering with the raw action
|
||||
cmd = self._connection._shell.append_command(cmd, 'sleep 0')
|
||||
if executable:
|
||||
cmd = executable + ' -c ' + pipes.quote(cmd)
|
||||
cmd = executable + ' -c ' + shlex_quote(cmd)
|
||||
|
||||
display.debug("_low_level_execute_command(): executing: %s" % (cmd,))
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import json
|
||||
import pipes
|
||||
import random
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible.compat.six import iteritems
|
||||
from ansible.compat.six.moves import shlex_quote
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.plugins.action import ActionBase
|
||||
|
||||
@@ -48,8 +48,6 @@ class ActionModule(ActionBase):
|
||||
|
||||
module_name = self._task.action
|
||||
|
||||
|
||||
|
||||
env_string = self._compute_environment_string()
|
||||
|
||||
module_args = self._task.args.copy()
|
||||
@@ -77,7 +75,7 @@ class ActionModule(ActionBase):
|
||||
elif module_style == 'old':
|
||||
args_data = ""
|
||||
for k, v in iteritems(module_args):
|
||||
args_data += '%s="%s" ' % (k, pipes.quote(to_text(v)))
|
||||
args_data += '%s="%s" ' % (k, shlex_quote(to_text(v)))
|
||||
argsfile = self._transfer_data(self._connection._shell.join_path(tmp, 'arguments'), args_data)
|
||||
|
||||
remote_paths = tmp, remote_module_path, remote_async_module_path
|
||||
|
||||
Reference in New Issue
Block a user