mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42: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 errno
|
||||
import fcntl
|
||||
import os
|
||||
import pipes
|
||||
import pty
|
||||
import select
|
||||
import subprocess
|
||||
@@ -30,6 +29,7 @@ import time
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible.compat.six import PY3, text_type, binary_type
|
||||
from ansible.compat.six.moves import shlex_quote
|
||||
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
|
||||
from ansible.errors import AnsibleOptionsError
|
||||
from ansible.module_utils.basic import BOOLEANS
|
||||
@@ -324,7 +324,7 @@ class Connection(ConnectionBase):
|
||||
Starts the command and communicates with it until it ends.
|
||||
'''
|
||||
|
||||
display_cmd = list(map(pipes.quote, map(to_text, cmd)))
|
||||
display_cmd = list(map(shlex_quote, map(to_text, cmd)))
|
||||
display.vvv(u'SSH: EXEC {0}'.format(u' '.join(display_cmd)), host=self.host)
|
||||
|
||||
# Start the given command. If we don't need to pipeline data, we can try
|
||||
@@ -626,9 +626,9 @@ class Connection(ConnectionBase):
|
||||
for method in methods:
|
||||
if method == 'sftp':
|
||||
cmd = self._build_command('sftp', to_bytes(host))
|
||||
in_data = u"{0} {1} {2}\n".format(sftp_action, pipes.quote(in_path), pipes.quote(out_path))
|
||||
in_data = u"{0} {1} {2}\n".format(sftp_action, shlex_quote(in_path), shlex_quote(out_path))
|
||||
elif method == 'scp':
|
||||
cmd = self._build_command('scp', in_path, u'{0}:{1}'.format(host, pipes.quote(out_path)))
|
||||
cmd = self._build_command('scp', in_path, u'{0}:{1}'.format(host, shlex_quote(out_path)))
|
||||
in_data = None
|
||||
|
||||
in_data = to_bytes(in_data, nonstring='passthru')
|
||||
|
||||
Reference in New Issue
Block a user