[libsoup] SoupAddress: fix handling of IPv6 literals



commit cb90c55a22ca5a4f97e624b2f69b3b93e6feba74
Author: Dan Winship <danw gnome org>
Date:   Sun Oct 7 18:24:12 2012 -0400

    SoupAddress: fix handling of IPv6 literals
    
    When generating a URI to pass to GProxyResolver, escape IPv6 literals properly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684990

 libsoup/soup-address.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/libsoup/soup-address.c b/libsoup/soup-address.c
index f2e698b..c298d3e 100644
--- a/libsoup/soup-address.c
+++ b/libsoup/soup-address.c
@@ -1200,20 +1200,25 @@ soup_address_connectable_proxy_enumerate (GSocketConnectable *connectable)
 	SoupAddress *addr = SOUP_ADDRESS (connectable);
 	SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
 	GSocketAddressEnumerator *proxy_enum;
-	char *uri;
+	SoupURI *uri;
+	char *uri_string;
 
 	/* We cheerily assume "http" here because you shouldn't be
 	 * using SoupAddress any more if you're not doing HTTP anyway.
 	 */
-	uri = g_strdup_printf ("%s://%s:%u",
-			       priv->protocol ? priv->protocol : "http",
-			       priv->name ? priv->name : soup_address_get_physical (addr),
-			       priv->port);
+	uri = soup_uri_new (NULL);
+	soup_uri_set_scheme (uri, priv->protocol ? priv->protocol : "http");
+	soup_uri_set_host (uri, priv->name ? priv->name : soup_address_get_physical (addr));
+	soup_uri_set_port (uri, priv->port);
+	soup_uri_set_path (uri, "");
+	uri_string = soup_uri_to_string (uri, FALSE);
+
 	proxy_enum = g_object_new (G_TYPE_PROXY_ADDRESS_ENUMERATOR,
 				   "connectable", connectable,
-				   "uri", uri,
+				   "uri", uri_string,
 				   NULL);
-	g_free (uri);
+	g_free (uri_string);
+	soup_uri_free (uri);
 
 	return proxy_enum;
 }



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