Since libvirt has existing support for creating URIs, use that rather than home-rolling our own code without any escaping. As a side-effect this ensures that URLs containing IPv6 addresses are escaped correctly, for example as below (note square brackets): https://[1234:56:0:789a:bcde:72ff:fe0a:7baa]:443/sdk Fixes: https://issues.redhat.com/browse/RHEL-138300 Updates: commit 845210011a9ffd9d17e30c51cbc81ba67c5d3166 Reported-by: Ming Xie <mxie@redhat.com> Signed-off-by: Richard W.M. Jones <rjones@redhat.com> --- src/esx/esx_driver.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 8fdfe0a656..9f8aae52bd 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -588,14 +588,14 @@ esxCreateURL(const char *transport, int port, const char *path) { - char *url; + virURI uri = { + .scheme = (char*)transport, + .server = (char*)server, + .port = port, + .path = (char*)path, + }; - url = g_strdup_printf("%s://%s:%d%s", - transport, - server, - port, - path); - return url; + return virURIFormat(&uri); } /* -- 2.52.0