mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Catch a unquoted line error. Fixes #6532
This commit is contained in:
parent
b8d5ba42f5
commit
94e3350b38
3 changed files with 10 additions and 3 deletions
|
@ -28,7 +28,6 @@ import collections
|
|||
import socket
|
||||
import base64
|
||||
import sys
|
||||
import shlex
|
||||
import pipes
|
||||
import jinja2
|
||||
import subprocess
|
||||
|
|
|
@ -58,6 +58,7 @@ class ActionModule(object):
|
|||
options = {}
|
||||
if complex_args:
|
||||
options.update(complex_args)
|
||||
|
||||
options.update(utils.parse_kv(module_args))
|
||||
|
||||
src = options.get('src', None)
|
||||
|
@ -65,6 +66,7 @@ class ActionModule(object):
|
|||
delimiter = options.get('delimiter', None)
|
||||
remote_src = utils.boolean(options.get('remote_src', 'yes'))
|
||||
|
||||
|
||||
if src is None or dest is None:
|
||||
result = dict(failed=True, msg="src and dest are required")
|
||||
return ReturnData(conn=conn, comm_ok=False, result=result)
|
||||
|
|
|
@ -539,8 +539,14 @@ def parse_kv(args):
|
|||
if args is not None:
|
||||
# attempting to split a unicode here does bad things
|
||||
args = args.encode('utf-8')
|
||||
vargs = [x.decode('utf-8') for x in shlex.split(args, posix=True)]
|
||||
#vargs = shlex.split(str(args), posix=True)
|
||||
try:
|
||||
vargs = shlex.split(args, posix=True)
|
||||
except ValueError, ve:
|
||||
if 'no closing quotation' in str(ve).lower():
|
||||
raise errors.AnsibleError("error parsing argument string, try quoting the entire line.")
|
||||
else:
|
||||
raise
|
||||
vargs = [x.decode('utf-8') for x in vargs]
|
||||
for x in vargs:
|
||||
if "=" in x:
|
||||
k, v = x.split("=",1)
|
||||
|
|
Loading…
Reference in a new issue