[gvfs] dav: Fix IPv6 address handling



commit 265c237408ec7a9ca0c02396b1e9d1bab265fb42
Author: Ondrej Holy <oholy redhat com>
Date:   Thu May 19 13:52:24 2016 +0200

    dav: Fix IPv6 address handling
    
    It is not possible to mount WebDAV share with IPv6 address currently.
    GMountSpec host contains brackets around the IPv6 address, however SoupURI
    doesn't. This patch handles this when converting GMountSpec to SoupURI
    and vice versa.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766631

 daemon/gvfsbackenddav.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c
index 37d55bc..4e28643 100644
--- a/daemon/gvfsbackenddav.c
+++ b/daemon/gvfsbackenddav.c
@@ -1652,7 +1652,12 @@ g_mount_spec_to_dav_uri (GMountSpec *spec)
     soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTP);
 
   soup_uri_set_user (uri, user);
-  soup_uri_set_host (uri, host);
+
+  /* IPv6 host does not include brackets in SoupURI, but GMountSpec host does */
+  if (host[0] == '[')
+    uri->host = g_strndup (host + 1, strlen (host) - 2);
+  else
+    soup_uri_set_host (uri, host);
 
   if (port && (port_num = atoi (port)))
     soup_uri_set_port (uri, port_num);
@@ -1693,7 +1698,15 @@ g_mount_spec_from_dav_uri (GVfsBackendDav *dav_backend,
 
   spec = g_mount_spec_new ("dav");
 
-  g_mount_spec_set (spec, "host", uri->host);
+  /* IPv6 host does not include brackets in SoupURI, but GMountSpec host does */
+  if (strchr (uri->host, ':'))
+    {
+      char *host = g_strdup_printf ("[%s]", uri->host);
+      g_mount_spec_set (spec, "host", host);
+      g_free (host);
+    }
+  else
+    g_mount_spec_set (spec, "host", uri->host);
 
   if (uri->scheme == SOUP_URI_SCHEME_HTTPS)
     ssl = "true";


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]