]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
esx: Switch to creating URLs using virURIFormat
authorRichard W.M. Jones <rjones@redhat.com>
Mon, 26 Jan 2026 17:54:57 +0000 (17:54 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 27 Jan 2026 16:56:00 +0000 (16:56 +0000)
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>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/esx/esx_driver.c

index 922f071fb1f6464cefbe463b02aba55bba441be0..010c62b8e880b89e02bc31799c8ed4db266849bf 100644 (file)
@@ -588,14 +588,14 @@ esxCreateURL(const char *transport,
              int port,
              const char *path)
 {
-    char *url;
-
-    url = g_strdup_printf("%s://%s:%d%s",
-                          transport,
-                          server,
-                          port,
-                          path);
-    return url;
+    virURI uri = {
+        .scheme = (char*)transport,
+        .server = (char*)server,
+        .port = port,
+        .path = (char*)path,
+    };
+
+    return virURIFormat(&uri);
 }
 
 /*