# HG changeset patch
# Node ID d41dd64add2a
# Parent  cdffd63bc0c9
diff --git a/libpurple/protocols/facebook/http.c b/libpurple/protocols/facebook/http.c
--- a/libpurple/protocols/facebook/http.c
+++ b/libpurple/protocols/facebook/http.c
@@ -58,7 +58,7 @@ fb_http_params_new(void)
 FbHttpParams *
 fb_http_params_new_parse(const gchar *data, gboolean isurl)
 {
-	SoupURI *uri = NULL;
+	gchar *query = NULL;
 	FbHttpParams *params;
 
 	if (data == NULL) {
@@ -66,20 +66,18 @@ fb_http_params_new_parse(const gchar *da
 	}
 
 	if (isurl) {
-		uri = soup_uri_new(data);
-
-		if (uri == NULL) {
+		if (!g_uri_split(data, G_URI_FLAGS_ENCODED_QUERY, NULL, NULL, NULL,
+		                 NULL, NULL, &query, NULL, NULL))
+		{
 			return fb_http_params_new();
 		}
 
-		data = uri->query;
+		data = query;
 	}
 
 	params = soup_form_decode(data);
 
-	if (isurl) {
-		soup_uri_free(uri);
-	}
+	g_free(query);
 
 	return params;
 }
@@ -232,9 +230,12 @@ fb_http_params_set_strf(FbHttpParams *pa
 gboolean
 fb_http_urlcmp(const gchar *url1, const gchar *url2, gboolean protocol)
 {
-	SoupURI *uri1;
-	SoupURI *uri2;
 	gboolean ret = TRUE;
+#if SOUP_MAJOR_VERSION >= 3
+	GUri *uri1, *uri2;
+#else
+	SoupURI *uri1, *uri2;
+#endif
 
 	if ((url1 == NULL) || (url2 == NULL)) {
 		return url1 == url2;
@@ -244,14 +245,43 @@ fb_http_urlcmp(const gchar *url1, const 
 		return TRUE;
 	}
 
+#if SOUP_MAJOR_VERSION >= 3
+	uri1 = g_uri_parse(url1, SOUP_HTTP_URI_FLAGS, NULL);
+	if (uri1 == NULL) {
+		return g_ascii_strcasecmp(url1, url2) == 0;
+	}
+
+	uri2 = g_uri_parse(url2, SOUP_HTTP_URI_FLAGS, NULL);
+	if (uri2 == NULL) {
+		g_uri_unref(uri1);
+		return g_ascii_strcasecmp(url1, url2) == 0;
+	}
+
+	if (!protocol) {
+		/* Force the same scheme (and same port). */
+		GUri *tmp = NULL;
+
+		tmp = soup_uri_copy(uri1,
+		                    SOUP_URI_SCHEME, "https",
+		                    SOUP_URI_PORT, 443,
+		                    SOUP_URI_NONE);
+		g_uri_unref(uri1);
+		uri1 = tmp;
+
+		tmp = soup_uri_copy(uri2,
+		                    SOUP_URI_SCHEME, "https",
+		                    SOUP_URI_PORT, 443,
+		                    SOUP_URI_NONE);
+		g_uri_unref(uri2);
+		uri2 = tmp;
+	}
+#else
 	uri1 = soup_uri_new(url1);
-
 	if (uri1 == NULL) {
 		return g_ascii_strcasecmp(url1, url2) == 0;
 	}
 
 	uri2 = soup_uri_new(url2);
-
 	if (uri2 == NULL) {
 		soup_uri_free(uri1);
 		return g_ascii_strcasecmp(url1, url2) == 0;
@@ -262,10 +292,16 @@ fb_http_urlcmp(const gchar *url1, const 
 		soup_uri_set_scheme(uri1, SOUP_URI_SCHEME_HTTPS);
 		soup_uri_set_scheme(uri2, SOUP_URI_SCHEME_HTTPS);
 	}
+#endif
 
 	ret = soup_uri_equal(uri1, uri2);
 
+#if SOUP_MAJOR_VERSION >= 3
+	g_uri_unref(uri1);
+	g_uri_unref(uri2);
+#else
 	soup_uri_free(uri1);
 	soup_uri_free(uri2);
+#endif
 	return ret;
 }
diff --git a/libpurple/protocols/jabber/bosh.c b/libpurple/protocols/jabber/bosh.c
--- a/libpurple/protocols/jabber/bosh.c
+++ b/libpurple/protocols/jabber/bosh.c
@@ -99,7 +99,7 @@ jabber_bosh_connection_new(JabberStream 
 	PurpleAccount *account;
 	GProxyResolver *resolver;
 	GError *error = NULL;
-	SoupURI *url_p;
+	const gchar *scheme;
 
 	account = purple_connection_get_account(js->gc);
 	resolver = purple_proxy_get_proxy_resolver(account, &error);
@@ -111,8 +111,8 @@ jabber_bosh_connection_new(JabberStream 
 		return NULL;
 	}
 
-	url_p = soup_uri_new(url);
-	if (!SOUP_URI_VALID_FOR_HTTP(url_p)) {
+	scheme = g_uri_peek_scheme(url);
+	if (scheme == NULL) {
 		purple_debug_error("jabber-bosh", "Unable to parse given BOSH URL: %s",
 		                   url);
 		g_object_unref(resolver);
@@ -127,7 +127,7 @@ jabber_bosh_connection_new(JabberStream 
 	        NULL);
 	conn->url = g_strdup(url);
 	conn->js = js;
-	conn->is_ssl = (url_p->scheme == SOUP_URI_SCHEME_HTTPS);
+	conn->is_ssl = g_str_equal(scheme, "https");
 	conn->send_buff = g_string_new(NULL);
 
 	/*
@@ -140,7 +140,6 @@ jabber_bosh_connection_new(JabberStream 
 	conn->rid = (((guint64)g_random_int() << 32) | g_random_int());
 	conn->rid &= 0xFFFFFFFFFFFFFLL;
 
-	soup_uri_free(url_p);
 	g_object_unref(resolver);
 
 	jabber_bosh_connection_session_create(conn);
diff --git a/libpurple/proxy.c b/libpurple/proxy.c
--- a/libpurple/proxy.c
+++ b/libpurple/proxy.c
@@ -552,23 +552,37 @@ purple_proxy_get_setup(PurpleAccount *ac
 			(tmp = g_getenv("http_proxy")) != NULL ||
 			(tmp = g_getenv("HTTPPROXY")) != NULL)
 		{
-			SoupURI *url;
+			gchar *scheme, *host, *username, *password;
+			gint port;
+			GError *error = NULL;
 
 			/* http_proxy-format:
 			 * export http_proxy="http://user:passwd@your.proxy.server:port/"
 			 */
-			url = soup_uri_new(tmp);
-			if (!SOUP_URI_VALID_FOR_HTTP(url)) {
+			if (!g_uri_split_with_user(tmp, G_URI_FLAGS_HAS_PASSWORD, &scheme,
+			                           &username, &password, NULL,
+			                           &host, &port, NULL, NULL, NULL, &error))
+			{
+				purple_debug_warning("proxy", "Couldn't parse URL: %s: %s", tmp, error->message);
+				g_error_free(error);
+				return gpi;
+			}
+			if (!purple_strequal(scheme, "http")) {
 				purple_debug_warning("proxy", "Couldn't parse URL: %s", tmp);
+				g_free(username);
+				g_free(password);
+				g_free(host);
 				return gpi;
 			}
 
-			purple_proxy_info_set_host(gpi, url->host);
-			purple_proxy_info_set_username(gpi, url->user);
-			purple_proxy_info_set_password(gpi, url->password);
-			purple_proxy_info_set_port(gpi, url->port);
+			purple_proxy_info_set_host(gpi, host);
+			purple_proxy_info_set_username(gpi, username);
+			purple_proxy_info_set_password(gpi, password);
+			purple_proxy_info_set_port(gpi, port);
 
-			soup_uri_free(url);
+			g_free(host);
+			g_free(username);
+			g_free(password);
 
 			/* XXX: Do we want to skip this step if user/password/port were part of url? */
 			if ((tmp = g_getenv("HTTP_PROXY_USER")) != NULL ||
diff --git a/libpurple/upnp.c b/libpurple/upnp.c
--- a/libpurple/upnp.c
+++ b/libpurple/upnp.c
@@ -420,7 +420,8 @@ static void
 purple_upnp_parse_description(const gchar* descriptionURL, UPnPDiscoveryData *dd)
 {
 	SoupMessage *msg;
-	SoupURI *uri;
+	gchar *host;
+	gint port;
 
 	/* Remove the timeout because everything it is waiting for has
 	 * successfully completed */
@@ -430,13 +431,14 @@ purple_upnp_parse_description(const gcha
 	/* Extract base url out of the descriptionURL.
 	 * Example description URL: http://192.168.1.1:5678/rootDesc.xml
 	 */
-	uri = soup_uri_new(descriptionURL);
-	if (!uri) {
+	if (!g_uri_split_network(descriptionURL, G_URI_FLAGS_NONE, NULL, &host,
+	                         &port, NULL))
+	{
 		upnp_parse_description_cb(NULL, NULL, dd);
 		return;
 	}
-	dd->full_url = g_strdup_printf("http://%s:%d", uri->host, uri->port);
-	soup_uri_free(uri);
+	dd->full_url = g_strdup_printf("http://%s:%d", host, port);
+	g_free(host);
 
 	msg = soup_message_new("GET", descriptionURL);
 	// purple_http_request_set_max_len(msg, MAX_UPNP_DOWNLOAD);
@@ -815,33 +817,35 @@ looked_up_internal_ip_cb(GObject *source
 static void
 lookup_internal_ip()
 {
-	SoupURI *uri;
+	gchar *host;
+	gint port;
 	GSocketClient *client;
 	GError *error = NULL;
 
-	uri = soup_uri_new(control_info.control_url);
-	if (!uri) {
+	if (!g_uri_split_network(control_info.control_url, G_URI_FLAGS_NONE, NULL,
+	                         &host, &port, &error))
+	{
 		purple_debug_error("upnp",
-			"lookup_internal_ip(): Failed In Parse URL\n");
+			"lookup_internal_ip(): Failed In Parse URL: %s",
+			error->message);
 		return;
 	}
 
 	client = purple_gio_socket_client_new(NULL, &error);
 	if (client == NULL) {
 		purple_debug_error("upnp", "Get Local IP Connect to %s:%d Failed: %s",
-		                   uri->host, uri->port, error->message);
+		                   host, port, error->message);
 		g_clear_error(&error);
-		soup_uri_free(uri);
+		g_free(host);
 		return;
 	}
 
-	purple_debug_info("upnp", "Attempting connection to %s:%u\n", uri->host,
-	                  uri->port);
-	g_socket_client_connect_to_host_async(client, uri->host, uri->port, NULL,
+	purple_debug_info("upnp", "Attempting connection to %s:%u\n", host, port);
+	g_socket_client_connect_to_host_async(client, host, port, NULL,
 	                                      looked_up_internal_ip_cb, NULL);
 
 	g_object_unref(client);
-	soup_uri_free(uri);
+	g_free(host);
 }
 
 static void
