From 8f7c8579607de043958ff713bf9c9adca38b8a30 Mon Sep 17 00:00:00 2001 From: Mike Healey Date: Sat, 27 Oct 2018 12:15:00 -0400 Subject: [PATCH] VMware: Add url quoting to support spaces in paths provided by the user (#46708) --- lib/ansible/modules/cloud/vmware/vsphere_copy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/vmware/vsphere_copy.py b/lib/ansible/modules/cloud/vmware/vsphere_copy.py index 84ddce5d9b..3c876b10ee 100644 --- a/lib/ansible/modules/cloud/vmware/vsphere_copy.py +++ b/lib/ansible/modules/cloud/vmware/vsphere_copy.py @@ -100,14 +100,14 @@ import socket import traceback from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.six.moves.urllib.parse import urlencode +from ansible.module_utils.six.moves.urllib.parse import urlencode, quote from ansible.module_utils._text import to_native from ansible.module_utils.urls import open_url def vmware_path(datastore, datacenter, path): ''' Constructs a URL path that VSphere accepts reliably ''' - path = "/folder/%s" % path.lstrip("/") + path = "/folder/%s" % quote(path.lstrip("/")) # Due to a software bug in vSphere, it fails to handle ampersand in datacenter names # The solution is to do what vSphere does (when browsing) and double-encode ampersands, maybe others ? datacenter = datacenter.replace('&', '%26')