Merged default branch soc.2013.gobjectification

Sun, 23 Jun 2013 13:35:53 +0530

author
Ankit Vani <a@nevitus.org>
date
Sun, 23 Jun 2013 13:35:53 +0530
branch
soc.2013.gobjectification
changeset 34619
b8d8c1516d74
parent 34618
949097b6b371 (current diff)
parent 34223
d3738c010ece (diff)
child 34620
e49aa67344e1

Merged default branch

.hgignore file | annotate | diff | comparison | revisions
libpurple/ciphers/descipher.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/bosh.c file | annotate | diff | comparison | revisions
libpurple/protocols/yahoo/yahoochat.c file | annotate | diff | comparison | revisions
libpurple/proxy.c file | annotate | diff | comparison | revisions
libpurple/tests/test_cipher.c file | annotate | diff | comparison | revisions
--- a/.hgignore	Sun Jun 23 03:51:11 2013 +0530
+++ b/.hgignore	Sun Jun 23 13:35:53 2013 +0530
@@ -1,3 +1,6 @@
+syntax: glob
+.*.swp
+
 syntax: regexp
 (.*/)?TAGS$
 (.*/)?\.svn
@@ -72,6 +75,7 @@
 libpurple/purple.h$
 libpurple/tests/check_libpurple
 libpurple/tests/libpurple..
+^libpurple/tests/test-suite\.log$
 libpurple/version.h$
 libpurple/win32/libpurplerc.rc$
 libtool
--- a/libpurple/http.c	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/http.c	Sun Jun 23 13:35:53 2013 +0530
@@ -125,7 +125,7 @@
 struct _PurpleHttpURL
 {
 	gchar *protocol;
-	gchar *user;
+	gchar *username;
 	gchar *password;
 	gchar *host;
 	int port;
@@ -2118,7 +2118,7 @@
 			return NULL;
 		}
 
-		url->user = g_match_info_fetch(match_info, 1);
+		url->username = g_match_info_fetch(match_info, 1);
 		url->password = g_match_info_fetch(match_info, 2);
 		url->host = g_match_info_fetch(match_info, 3);
 		port_str = g_match_info_fetch(match_info, 4);
@@ -2126,9 +2126,9 @@
 		if (port_str && port_str[0])
 			url->port = atoi(port_str);
 
-		if (url->user[0] == '\0') {
-			g_free(url->user);
-			url->user = NULL;
+		if (url->username[0] == '\0') {
+			g_free(url->username);
+			url->username = NULL;
 		}
 		if (url->password[0] == '\0') {
 			g_free(url->password);
@@ -2174,7 +2174,7 @@
 		return;
 
 	g_free(parsed_url->protocol);
-	g_free(parsed_url->user);
+	g_free(parsed_url->username);
 	g_free(parsed_url->password);
 	g_free(parsed_url->host);
 	g_free(parsed_url->path);
@@ -2191,8 +2191,8 @@
 	if (relative_url->host) {
 		g_free(base_url->protocol);
 		base_url->protocol = g_strdup(relative_url->protocol);
-		g_free(base_url->user);
-		base_url->user = g_strdup(relative_url->user);
+		g_free(base_url->username);
+		base_url->username = g_strdup(relative_url->username);
 		g_free(base_url->password);
 		base_url->password = g_strdup(relative_url->password);
 		g_free(base_url->host);
@@ -2243,9 +2243,9 @@
 			"https"))
 			port_is_default = TRUE;
 	}
-	if (parsed_url->user || parsed_url->password) {
-		if (parsed_url->user)
-			g_string_append(url, parsed_url->user);
+	if (parsed_url->username || parsed_url->password) {
+		if (parsed_url->username)
+			g_string_append(url, parsed_url->username);
 		g_string_append_printf(url, ":%s", parsed_url->password);
 		g_string_append(url, "@");
 		before_host_printed = TRUE;
@@ -2282,11 +2282,11 @@
 }
 
 const gchar *
-purple_http_url_get_user(const PurpleHttpURL *parsed_url)
+purple_http_url_get_username(const PurpleHttpURL *parsed_url)
 {
 	g_return_val_if_fail(parsed_url != NULL, NULL);
 
-	return parsed_url->user;
+	return parsed_url->username;
 }
 
 const gchar *
--- a/libpurple/http.h	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/http.h	Sun Jun 23 13:35:53 2013 +0530
@@ -284,7 +284,7 @@
  * @return           The username.
  */
 const gchar *
-purple_http_url_get_user(const PurpleHttpURL *parsed_url);
+purple_http_url_get_username(const PurpleHttpURL *parsed_url);
 
 /**
  * Gets the password part of URL.
--- a/libpurple/obsolete.c	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/obsolete.c	Sun Jun 23 13:35:53 2013 +0530
@@ -76,6 +76,22 @@
 	gpointer user_data;
 } PurpleUtilLegacyWrapData;
 
+/**
+ * Parses a URL, returning its host, port, file path, username and password.
+ *
+ * The returned data must be freed.
+ *
+ * @param url      The URL to parse.
+ * @param ret_host The returned host.
+ * @param ret_port The returned port.
+ * @param ret_path The returned path.
+ * @param ret_user The returned username.
+ * @param ret_passwd The returned password.
+ */
+static gboolean purple_url_parse(const char *url, char **ret_host, int *ret_port,
+	char **ret_path, char **ret_user, char **ret_passwd);
+
+
 static void purple_util_fetch_url_cb(PurpleHttpConnection *http_conn,
 	PurpleHttpResponse *response, gpointer _wrap_data)
 {
@@ -786,7 +802,7 @@
  *       purple_util_fetch_url() ignores the "https" and attempts to
  *       fetch the URL via http again, which gets redirected again.
  */
-gboolean
+static gboolean
 purple_url_parse(const char *url, char **ret_host, int *ret_port,
 			   char **ret_path, char **ret_user, char **ret_passwd)
 {
--- a/libpurple/obsolete.h	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/obsolete.h	Sun Jun 23 13:35:53 2013 +0530
@@ -104,22 +104,6 @@
  */
 void purple_util_fetch_url_cancel(PurpleUtilFetchUrlData *url_data);
 
-/**
- * Parses a URL, returning its host, port, file path, username and password.
- *
- * The returned data must be freed.
- *
- * @param url      The URL to parse.
- * @param ret_host The returned host.
- * @param ret_port The returned port.
- * @param ret_path The returned path.
- * @param ret_user The returned username.
- * @param ret_passwd The returned password.
- */
-gboolean purple_url_parse(const char *url, char **ret_host, int *ret_port,
-						char **ret_path, char **ret_user, char **ret_passwd);
-
-
 /*@}*/
 
 #endif /* _PURPLE_OBSOLETE_H_ */
--- a/libpurple/protocols/jabber/bosh.c	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/protocols/jabber/bosh.c	Sun Jun 23 13:35:53 2013 +0530
@@ -25,7 +25,7 @@
 #include "core.h"
 #include "cipher.h"
 #include "debug.h"
-#include "obsolete.h"
+#include "http.h"
 #include "prpl.h"
 #include "util.h"
 #include "xmlnode.h"
@@ -200,33 +200,33 @@
 jabber_bosh_connection_init(JabberStream *js, const char *url)
 {
 	PurpleBOSHConnection *conn;
-	char *host, *path, *user, *passwd;
-	int port;
+	PurpleHttpURL *url_p;
 
-	if (!purple_url_parse(url, &host, &port, &path, &user, &passwd)) {
+	url_p = purple_http_url_parse(url);
+	if (!url_p) {
 		purple_debug_info("jabber", "Unable to parse given URL.\n");
 		return NULL;
 	}
 
 	conn = g_new0(PurpleBOSHConnection, 1);
-	conn->host = host;
-	conn->port = port;
-	conn->path = g_strdup_printf("/%s", path);
-	g_free(path);
+	conn->host = g_strdup(purple_http_url_get_host(url_p));
+	conn->port = purple_http_url_get_port(url_p);
+	conn->path = g_strdup(purple_http_url_get_path(url_p));
 	conn->pipelining = TRUE;
 
-	if (purple_ip_address_is_valid(host))
+	if (purple_ip_address_is_valid(purple_http_url_get_host(url_p)))
 		js->serverFQDN = g_strdup(js->user->domain);
 	else
-		js->serverFQDN = g_strdup(host);
+		js->serverFQDN = g_strdup(purple_http_url_get_host(url_p));
 
-	if ((user && user[0] != '\0') || (passwd && passwd[0] != '\0')) {
+	if (purple_http_url_get_username(url_p) ||
+		purple_http_url_get_password(url_p))
+	{
 		purple_debug_info("jabber", "Ignoring unexpected username and password "
 		                            "in BOSH URL.\n");
 	}
 
-	g_free(user);
-	g_free(passwd);
+	purple_http_url_free(url_p);
 
 	conn->js = js;
 
--- a/libpurple/protocols/jabber/oob.c	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/protocols/jabber/oob.c	Sun Jun 23 13:35:53 2013 +0530
@@ -23,7 +23,7 @@
 #include "internal.h"
 #include "debug.h"
 #include "ft.h"
-#include "obsolete.h"
+#include "http.h"
 #include "util.h"
 
 #include "jabber.h"
@@ -200,8 +200,9 @@
 	JabberOOBXfer *jox;
 	PurpleXfer *xfer;
 	char *filename;
-	char *url;
+	char *url_raw;
 	xmlnode *urlnode;
+	PurpleHttpURL *url;
 
 	if(type != JABBER_IQ_SET)
 		return;
@@ -212,15 +213,20 @@
 	if(!(urlnode = xmlnode_get_child(querynode, "url")))
 		return;
 
-	url = xmlnode_get_data(urlnode);
+	url_raw = xmlnode_get_data(urlnode);
+	url = purple_http_url_parse(url_raw);
+	g_free(url_raw);
+
+	if (!url)
+		return;
 
 	jox = g_new0(JabberOOBXfer, 1);
-	if (!purple_url_parse(url, &jox->address, &jox->port, &jox->page, NULL, NULL)) {
-		g_free(url);
-		g_free(jox);
-		return;
-	}
-	g_free(url);
+	jox->address = g_strdup(purple_http_url_get_host(url));
+	jox->port = purple_http_url_get_port(url);
+	jox->page = g_strdup(purple_http_url_get_path(url));
+
+	purple_http_url_free(url);
+
 	jox->js = js;
 	jox->headers = g_string_new("");
 	jox->iq_id = g_strdup(id);
--- a/libpurple/protocols/msn/soap.c	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/protocols/msn/soap.c	Sun Jun 23 13:35:53 2013 +0530
@@ -27,7 +27,7 @@
 
 #include "soap.h"
 
-#include "obsolete.h"
+#include "http.h"
 #include "session.h"
 
 #include "debug.h"
@@ -270,27 +270,28 @@
 }
 
 static gboolean
-msn_soap_handle_redirect(MsnSoapConnection *conn, const char *url)
+msn_soap_handle_redirect(MsnSoapConnection *conn, const char *url_raw)
 {
-	char *host;
-	char *path;
+	MsnSoapRequest *req;
+	PurpleHttpURL *url;
 
-	if (purple_url_parse(url, &host, NULL, &path, NULL, NULL)) {
-		MsnSoapRequest *req = conn->current_request;
-		conn->current_request = NULL;
+	url = purple_http_url_parse(url_raw);
+	if (!url)
+		return FALSE;
 
-		msn_soap_message_send_internal(conn->session, req->message, host, path,
-			req->secure, req->cb, req->cb_data, TRUE);
+	req = conn->current_request;
+	conn->current_request = NULL;
 
-		msn_soap_request_destroy(req, TRUE);
+	msn_soap_message_send_internal(conn->session, req->message,
+		purple_http_url_get_host(url), purple_http_url_get_path(url),
+		req->secure, req->cb, req->cb_data, TRUE);
 
-		g_free(host);
-		g_free(path);
+	msn_soap_request_destroy(req, TRUE);
 
-		return TRUE;
-	}
+	purple_http_url_free(url);
 
-	return FALSE;
+	return TRUE;
+
 }
 
 static gboolean
--- a/libpurple/protocols/mxit/http.c	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/protocols/mxit/http.c	Sun Jun 23 13:35:53 2013 +0530
@@ -317,7 +317,7 @@
  *	@param data			The HTTP request data (including HTTP headers etc.)
  *	@param datalen		The HTTP request data length
  */
-void mxit_http_send_request( struct MXitSession* session, char* host, int port, const char* data, int datalen )
+void mxit_http_send_request( struct MXitSession* session, const char* host, int port, const char* data, int datalen )
 {
 	PurpleProxyConnectData*		con	= NULL;
 	struct http_request*		req;
@@ -325,7 +325,7 @@
 	/* build the http request */
 	req = g_new0( struct http_request, 1 );
 	req->session = session;
-	req->host = host;
+	req->host = g_strdup(host);
 	req->port = port;
 	req->data = g_malloc0( datalen );
 	memcpy( req->data, data, datalen );
--- a/libpurple/protocols/mxit/http.h	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/protocols/mxit/http.h	Sun Jun 23 13:35:53 2013 +0530
@@ -39,7 +39,7 @@
 };
 
 
-void mxit_http_send_request( struct MXitSession* session, char* host, int port, const char* data, int datalen );
+void mxit_http_send_request( struct MXitSession* session, const char* host, int port, const char* data, int datalen );
 
 
 
--- a/libpurple/protocols/mxit/protocol.c	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/protocols/mxit/protocol.c	Sun Jun 23 13:35:53 2013 +0530
@@ -38,6 +38,7 @@
 #include	"splashscreen.h"
 #include	"login.h"
 #include	"formcmds.h"
+#include	<libpurple/http.h>
 #include	"http.h"
 #include	"cipher.h"
 #include	"voicevideo.h"
@@ -338,14 +339,13 @@
 {
 	char		request[256 + packet->datalen];
 	int			reqlen;
-	char*		host_name;
-	int			host_port;
-	gboolean	ok;
+	PurpleHttpURL *url;
 
 	/* extract the HTTP host name and host port number to connect to */
-	ok = purple_url_parse( session->http_server, &host_name, &host_port, NULL, NULL, NULL );
-	if ( !ok ) {
+	url = purple_http_url_parse(session->http_server);
+	if (url == NULL) {
 		purple_debug_error( MXIT_PLUGIN_ID, "HTTP POST error: (host name '%s' not valid)\n", session->http_server );
+		return;
 	}
 
 	/* strip off the last '&' from the header */
@@ -362,7 +362,7 @@
 					"\r\n",
 					session->http_server,
 					purple_url_encode( packet->header ),
-					host_name,
+					purple_http_url_get_host(url),
 					packet->datalen - MXIT_MS_OFFSET
 	);
 
@@ -376,7 +376,10 @@
 #endif
 
 	/* send the request to the HTTP server */
-	mxit_http_send_request( session, host_name, host_port, request, reqlen );
+	mxit_http_send_request(session, purple_http_url_get_host(url),
+		purple_http_url_get_port(url), request, reqlen);
+
+	purple_http_url_free(url);
 }
 
 
--- a/libpurple/protocols/yahoo/yahoo_aliases.c	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/protocols/yahoo/yahoo_aliases.c	Sun Jun 23 13:35:53 2013 +0530
@@ -29,6 +29,7 @@
 #include "accountopt.h"
 #include "blist.h"
 #include "debug.h"
+#include "http.h"
 #include "util.h"
 #include "request.h"
 #include "version.h"
@@ -189,23 +190,26 @@
 {
 	YahooData *yd = purple_connection_get_protocol_data(gc);
 	const char *url;
-	gchar *request, *webpage, *webaddress;
+	gchar *request;
 	PurpleUtilFetchUrlData *url_data;
+	PurpleHttpURL *url_p;
 
 	/* use whole URL if using HTTP Proxy */
 	gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
 
 	/*  Build all the info to make the web request */
 	url = yd->jp ? YAHOOJP_ALIAS_FETCH_URL : YAHOO_ALIAS_FETCH_URL;
-	purple_url_parse(url, &webaddress, NULL, &webpage, NULL, NULL);
-	request = g_strdup_printf("GET %s%s/%s HTTP/1.1\r\n"
+	url_p = purple_http_url_parse(url);
+	g_assert(url_p != NULL);
+
+	request = g_strdup_printf("GET %s%s%s HTTP/1.1\r\n"
 				 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
 				 "Cookie: T=%s; Y=%s\r\n"
 				 "Host: %s\r\n"
 				 "Cache-Control: no-cache\r\n\r\n",
-				  use_whole_url ? "http://" : "", use_whole_url ? webaddress : "", webpage,
+				  use_whole_url ? "http://" : "", use_whole_url ? purple_http_url_get_host(url_p) : "", purple_http_url_get_path(url_p),
 				  yd->cookie_t, yd->cookie_y,
-				  webaddress);
+				  purple_http_url_get_host(url_p));
 
 	/* We have a URL and some header information, let's connect and get some aliases  */
 	url_data = purple_util_fetch_url_request(purple_connection_get_account(gc),
@@ -214,8 +218,7 @@
 	if (url_data != NULL)
 		yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
 
-	g_free(webaddress);
-	g_free(webpage);
+	purple_http_url_free(url_p);
 	g_free(request);
 }
 
@@ -292,9 +295,10 @@
 {
 	YahooData *yd;
 	const char *url;
-	gchar *content, *request, *webpage, *webaddress;
+	gchar *content, *request;
 	struct callback_data *cb;
 	PurpleUtilFetchUrlData *url_data;
+	PurpleHttpURL *url_p;
 	YahooFriend *f;
 	/* use whole URL if using HTTP Proxy */
 	gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
@@ -321,7 +325,9 @@
 
 	/*  Build all the info to make the web request */
 	url = yd->jp ? YAHOOJP_ALIAS_UPDATE_URL: YAHOO_ALIAS_UPDATE_URL;
-	purple_url_parse(url, &webaddress, NULL, &webpage, NULL, NULL);
+
+	url_p = purple_http_url_parse(url);
+	g_assert(url_p != NULL);
 
 	if (cb->id == NULL) {
 		/* No id for this buddy, so create an address book entry */
@@ -366,16 +372,16 @@
 		}
 	}
 
-	request = g_strdup_printf("POST %s%s/%s HTTP/1.1\r\n"
+	request = g_strdup_printf("POST %s%s%s HTTP/1.1\r\n"
 				  "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
 				  "Cookie: T=%s; Y=%s\r\n"
 				  "Host: %s\r\n"
 				  "Content-Length: %" G_GSIZE_FORMAT "\r\n"
 				  "Cache-Control: no-cache\r\n\r\n"
 				  "%s",
-				  use_whole_url ? "http://" : "", use_whole_url ? webaddress : "", webpage,
+				  use_whole_url ? "http://" : "", use_whole_url ? purple_http_url_get_host(url_p) : "", purple_http_url_get_path(url_p),
 				  yd->cookie_t, yd->cookie_y,
-				  webaddress,
+				  purple_http_url_get_host(url_p),
 				  strlen(content),
 				  content);
 
@@ -386,8 +392,7 @@
 	if (url_data != NULL)
 		yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
 
-	g_free(webpage);
-	g_free(webaddress);
+	purple_http_url_free(url_p);
 	g_free(content);
 	g_free(request);
 }
@@ -456,7 +461,7 @@
 	YahooData *yd = purple_connection_get_protocol_data(gc);
 	PurpleAccount *account;
 	PurpleUtilFetchUrlData *url_data;
-	char *webaddress, *webpage;
+	PurpleHttpURL *url_p;
 	char *request, *content;
 	int len;
 	int i;
@@ -479,7 +484,9 @@
 
 	content = xmlnode_to_formatted_str(node, &len);
 	xmlnode_free(node);
-	purple_url_parse(yd->jp ? YAHOOJP_USERINFO_URL : YAHOO_USERINFO_URL, &webaddress, NULL, &webpage, NULL, NULL);
+
+	url_p = purple_http_url_parse(yd->jp ? YAHOOJP_USERINFO_URL : YAHOO_USERINFO_URL);
+	g_assert(url_p != NULL);
 
 	request = g_strdup_printf("POST %s HTTP/1.1\r\n"
 				  "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
@@ -488,9 +495,9 @@
 				  "Content-Length: %d\r\n"
 				  "Cache-Control: no-cache\r\n\r\n"
 				  "%s\r\n\r\n",
-				  webpage,
+				  purple_http_url_get_path(url_p),
 				  yd->cookie_t, yd->cookie_y,
-				  webaddress,
+				  purple_http_url_get_host(url_p),
 				  len + 4,
 				  content);
 
@@ -518,14 +525,13 @@
 	}
 #endif
 
-	url_data = purple_util_fetch_url_request(account, webaddress, FALSE,
+	url_data = purple_util_fetch_url_request(account, purple_http_url_get_host(url_p), FALSE,
 			YAHOO_CLIENT_USERAGENT, TRUE, request, FALSE, -1,
 			yahoo_fetch_aliases_cb, gc);
 	if (url_data != NULL)
 		yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
 
-	g_free(webaddress);
-	g_free(webpage);
+	purple_http_url_free(url_p);
 	g_free(content);
 	g_free(request);
 }
--- a/libpurple/protocols/yahoo/yahoo_filexfer.c	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/protocols/yahoo/yahoo_filexfer.c	Sun Jun 23 13:35:53 2013 +0530
@@ -26,9 +26,9 @@
 #include "prpl.h"
 #include "util.h"
 #include "debug.h"
+#include "http.h"
 #include "network.h"
 #include "notify.h"
-#include "obsolete.h"
 #include "proxy.h"
 #include "ft.h"
 #include "libymsg.h"
@@ -796,6 +796,7 @@
 	char *url = NULL;
 	char *imv = NULL;
 	PurpleXfer *xfer;
+	PurpleHttpURL *url_p;
 	YahooData *yd;
 	struct yahoo_xfer_data *xfer_data;
 	char *service = NULL;
@@ -866,10 +867,17 @@
 	/* Setup the Yahoo-specific file transfer data */
 	xfer_data = g_new0(struct yahoo_xfer_data, 1);
 	xfer_data->gc = gc;
-	if (!purple_url_parse(url, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL)) {
+
+	url_p = purple_http_url_parse(url);
+	if (!url_p) {
 		g_free(xfer_data);
+		purple_debug_error("yahoo_filexfer", "Couldn't parse URL\n");
 		return;
 	}
+	xfer_data->host = g_strdup(purple_http_url_get_host(url_p));
+	xfer_data->port = purple_http_url_get_port(url_p);
+	xfer_data->path = g_strdup(purple_http_url_get_path(url_p));
+	purple_http_url_free(url_p);
 
 	purple_debug_misc("yahoo_filexfer", "Host is %s, port is %d, path is %s, and the full url was %s.\n",
 	                xfer_data->host, xfer_data->port, xfer_data->path, url);
@@ -982,6 +990,7 @@
 	unsigned char a,b,c,d;
 	PurpleConnection *gc;
 	PurpleAccount *account;
+	PurpleHttpURL *url_p;
 	YahooData *yd;
 	gchar *url;
 	gchar *filename;
@@ -1040,12 +1049,16 @@
 		hosts = g_slist_remove(hosts, hosts->data);
 	}
 
-	if (!purple_url_parse(url, &(xd->host), &(xd->port), &(xd->path), NULL, NULL)) {
+	url_p = purple_http_url_parse(url);
+	g_free(url);
+	if (!url_p) {
 		purple_xfer_cancel_remote(xfer);
-		g_free(url);
 		return;
 	}
-	g_free(url);
+	xd->host = g_strdup(purple_http_url_get_host(url_p));
+	xd->port = purple_http_url_get_port(url_p);
+	xd->path = g_strdup(purple_http_url_get_path(url_p));
+	purple_http_url_free(url_p);
 
 	pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_INFO_15, YAHOO_STATUS_AVAILABLE, yd->session_id);
 	filename = g_path_get_basename(purple_xfer_get_local_filename(xfer));
@@ -1828,10 +1841,17 @@
 	xfer_data->xfer_idstring_for_relay = g_strdup(xfer_idstring_for_relay);
 	if(val_249 == 1 || val_249 == 3) {
 		PurpleAccount *account;
-		if (!purple_url_parse(url, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL)) {
+		PurpleHttpURL *url_p;
+
+		url_p = purple_http_url_parse(url);
+		if (!url_p) {
 			purple_xfer_cancel_remote(xfer);
 			return;
 		}
+		xfer_data->host = g_strdup(purple_http_url_get_host(url_p));
+		xfer_data->port = purple_http_url_get_port(url_p);
+		xfer_data->path = g_strdup(purple_http_url_get_path(url_p));
+		purple_http_url_free(url_p);
 
 		account = purple_connection_get_account(xfer_data->gc);
 
@@ -1920,8 +1940,18 @@
 	}
 
 	xfer_data = purple_xfer_get_protocol_data(xfer);
-	if(url)
-		purple_url_parse(url, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL);
+	if (url) {
+		PurpleHttpURL *url_p = purple_http_url_parse(url);
+		if (!url_p) {
+			purple_debug_error("yahoo", "Invalid URL\n");
+			purple_xfer_cancel_remote(xfer);
+			return;
+		}
+		xfer_data->host = g_strdup(purple_http_url_get_host(url_p));
+		xfer_data->port = purple_http_url_get_port(url_p);
+		xfer_data->path = g_strdup(purple_http_url_get_path(url_p));
+		purple_http_url_free(url_p);
+	}
 
 	xfer_data->xfer_idstring_for_relay = g_strdup(xfer_idstring_for_relay);
 	xfer_data->status_15 = ACCEPTED;
--- a/libpurple/protocols/yahoo/yahoochat.c	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/protocols/yahoo/yahoochat.c	Sun Jun 23 13:35:53 2013 +0530
@@ -33,7 +33,7 @@
 #endif /* HAVE_CONFIG_H */
 
 #include "debug.h"
-#include "obsolete.h"
+#include "http.h"
 #include "prpl.h"
 
 #include "conversation.h"
@@ -1501,6 +1501,7 @@
 	PurpleAccount *account;
 	PurpleRoomlist *rl;
 	PurpleRoomlistField *f;
+	PurpleHttpURL *url_p;
 	GList *fields = NULL;
 	struct yahoo_roomlist *yrl;
 	const char *rll, *rlurl;
@@ -1525,8 +1526,15 @@
 	rl = purple_roomlist_new(account);
 	yrl->list = rl;
 
-	purple_url_parse(url, &(yrl->host), NULL, &(yrl->path), NULL, NULL);
+	url_p = purple_http_url_parse(url);
 	g_free(url);
+	if (!url_p) {
+		purple_debug_error("yahoo", "Couldn't parse URL\n");
+		return NULL;
+	}
+	yrl->host = g_strdup(purple_http_url_get_host(url_p));
+	yrl->path = g_strdup(purple_http_url_get_path(url_p));
+	purple_http_url_free(url_p);
 
 	f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", "room", TRUE);
 	fields = g_list_append(fields, f);
@@ -1583,6 +1591,7 @@
 void yahoo_roomlist_expand_category(PurpleRoomlist *list, PurpleRoomlistRoom *category)
 {
 	PurpleAccount *account;
+	PurpleHttpURL *url_p;
 	struct yahoo_roomlist *yrl;
 	char *url;
 	char *id;
@@ -1619,8 +1628,15 @@
 	proto_data = g_list_append(proto_data, yrl);
 	purple_roomlist_set_proto_data(list, proto_data);
 
-	purple_url_parse(url, &(yrl->host), NULL, &(yrl->path), NULL, NULL);
+	url_p = purple_http_url_parse(url);
 	g_free(url);
+	if (!url_p) {
+		purple_debug_error("yahoo", "Couldn't parse URL\n");
+		return;
+	}
+	yrl->host = g_strdup(purple_http_url_get_host(url_p));
+	yrl->path = g_strdup(purple_http_url_get_path(url_p));
+	purple_http_url_free(url_p);
 
 	yrl->ucat = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_CATEGORY, _("User Rooms"), yrl->cat);
 	purple_roomlist_room_add(list, yrl->ucat);
--- a/libpurple/proxy.c	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/proxy.c	Sun Jun 23 13:35:53 2013 +0530
@@ -35,6 +35,7 @@
 #include "ciphers/md5hash.h"
 #include "debug.h"
 #include "dnsquery.h"
+#include "http.h"
 #include "notify.h"
 #include "ntlm.h"
 #include "obsolete.h"
@@ -2271,44 +2272,39 @@
 	if (purple_proxy_info_get_type(gpi) == PURPLE_PROXY_USE_ENVVAR) {
 		if ((tmp = g_getenv("HTTP_PROXY")) != NULL ||
 			(tmp = g_getenv("http_proxy")) != NULL ||
-			(tmp = g_getenv("HTTPPROXY")) != NULL) {
-			char *proxyhost, *proxyuser, *proxypasswd;
-			int proxyport;
+			(tmp = g_getenv("HTTPPROXY")) != NULL)
+		{
+			PurpleHttpURL *url;
 
 			/* http_proxy-format:
 			 * export http_proxy="http://user:passwd@your.proxy.server:port/"
 			 */
-			if(purple_url_parse(tmp, &proxyhost, &proxyport, NULL, &proxyuser, &proxypasswd)) {
-				purple_proxy_info_set_host(gpi, proxyhost);
-				g_free(proxyhost);
-
-				purple_proxy_info_set_username(gpi, proxyuser);
-				g_free(proxyuser);
-
-				purple_proxy_info_set_password(gpi, proxypasswd);
-				g_free(proxypasswd);
-
-				/* only for backward compatibility */
-				if (proxyport == 80 &&
-				    ((tmp = g_getenv("HTTP_PROXY_PORT")) != NULL ||
-				     (tmp = g_getenv("http_proxy_port")) != NULL ||
-				     (tmp = g_getenv("HTTPPROXYPORT")) != NULL))
-					proxyport = atoi(tmp);
-
-				purple_proxy_info_set_port(gpi, proxyport);
-
-				/* XXX: Do we want to skip this step if user/password were part of url? */
-				if ((tmp = g_getenv("HTTP_PROXY_USER")) != NULL ||
-					(tmp = g_getenv("http_proxy_user")) != NULL ||
-					(tmp = g_getenv("HTTPPROXYUSER")) != NULL)
-					purple_proxy_info_set_username(gpi, tmp);
-
-				if ((tmp = g_getenv("HTTP_PROXY_PASS")) != NULL ||
-					(tmp = g_getenv("http_proxy_pass")) != NULL ||
-					(tmp = g_getenv("HTTPPROXYPASS")) != NULL)
-					purple_proxy_info_set_password(gpi, tmp);
-
+			url = purple_http_url_parse(tmp);
+			if (!url) {
+				purple_debug_warning("proxy", "Couldn't parse URL\n");
+				return gpi;
 			}
+
+			purple_proxy_info_set_host(gpi, purple_http_url_get_host(url));
+			purple_proxy_info_set_username(gpi, purple_http_url_get_username(url));
+			purple_proxy_info_set_password(gpi, purple_http_url_get_password(url));
+			purple_proxy_info_set_port(gpi, purple_http_url_get_port(url));
+
+			/* XXX: Do we want to skip this step if user/password/port were part of url? */
+			if ((tmp = g_getenv("HTTP_PROXY_USER")) != NULL ||
+				(tmp = g_getenv("http_proxy_user")) != NULL ||
+				(tmp = g_getenv("HTTPPROXYUSER")) != NULL)
+				purple_proxy_info_set_username(gpi, tmp);
+
+			if ((tmp = g_getenv("HTTP_PROXY_PASS")) != NULL ||
+				(tmp = g_getenv("http_proxy_pass")) != NULL ||
+				(tmp = g_getenv("HTTPPROXYPASS")) != NULL)
+				purple_proxy_info_set_password(gpi, tmp);
+
+			if ((tmp = g_getenv("HTTP_PROXY_PORT")) != NULL ||
+				(tmp = g_getenv("http_proxy_port")) != NULL ||
+				(tmp = g_getenv("HTTPPROXYPORT")) != NULL)
+				purple_proxy_info_set_port(gpi, atoi(tmp));
 		} else {
 #ifdef _WIN32
 			PurpleProxyInfo *wgpi;
--- a/libpurple/tests/test_cipher.c	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/tests/test_cipher.c	Sun Jun 23 13:35:53 2013 +0530
@@ -265,11 +265,11 @@
 	purple_cipher_set_key(cipher, key, 8); \
 	\
 	ret = purple_cipher_encrypt(cipher, decrypt, len, answer, len); \
-	fail_unless(ret != 0, NULL); \
+	fail_unless(ret == len, NULL); \
 	fail_unless(memcmp(encrypt, answer, len) == 0, NULL); \
 	\
 	ret = purple_cipher_decrypt(cipher, encrypt, len, answer, len); \
-	fail_unless(ret != 0, NULL); \
+	fail_unless(ret == len, NULL); \
 	fail_unless(memcmp(decrypt, answer, len) == 0, NULL); \
 	\
 	g_object_unref(cipher); \
@@ -310,11 +310,11 @@
 	purple_cipher_set_iv(cipher, (guchar *)iv, 8); \
 	\
 	ret = purple_cipher_encrypt(cipher, decrypt, len, answer, len); \
-	fail_unless(ret != 0, NULL); \
+	fail_unless(ret == len, NULL); \
 	fail_unless(memcmp(encrypt, answer, len) == 0, NULL); \
 	\
 	ret = purple_cipher_decrypt(cipher, encrypt, len, answer, len); \
-	fail_unless(ret != 0, NULL); \
+	fail_unless(ret == len, NULL); \
 	fail_unless(memcmp(decrypt, answer, len) == 0, NULL); \
 	\
 	g_object_unref(cipher); \
--- a/libpurple/upnp.c	Sun Jun 23 03:51:11 2013 +0530
+++ b/libpurple/upnp.c	Sun Jun 23 13:35:53 2013 +0530
@@ -29,6 +29,7 @@
 
 #include "debug.h"
 #include "eventloop.h"
+#include "http.h"
 #include "network.h"
 #include "proxy.h"
 #include "signals.h"
@@ -432,36 +433,30 @@
 static void
 purple_upnp_parse_description(const gchar* descriptionURL, UPnPDiscoveryData *dd)
 {
+	PurpleHttpURL *url;
 	gchar* httpRequest;
-	gchar* descriptionXMLAddress;
-	gchar* descriptionAddress;
-	int port = 0;
 
 	/* parse the 4 above variables out of the descriptionURL
 	   example description URL: http://192.168.1.1:5678/rootDesc.xml */
 
-	/* parse the url into address, port, path variables */
-	if(!purple_url_parse(descriptionURL, &descriptionAddress,
-			&port, &descriptionXMLAddress, NULL, NULL)) {
+	url = purple_http_url_parse(descriptionURL);
+	if (!url)
 		return;
-	}
-	if(port == 0 || port == -1) {
-		port = DEFAULT_HTTP_PORT;
-	}
 
 	/* for example...
 	   GET /rootDesc.xml HTTP/1.1\r\nHost: 192.168.1.1:5678\r\n\r\n */
 	httpRequest = g_strdup_printf(
-		"GET /%s HTTP/1.1\r\n"
+		"GET %s HTTP/1.1\r\n"
 		"Connection: close\r\n"
 		"Host: %s:%d\r\n\r\n",
-		descriptionXMLAddress, descriptionAddress, port);
-
-	g_free(descriptionXMLAddress);
+		purple_http_url_get_path(url),
+		purple_http_url_get_host(url),
+		purple_http_url_get_port(url));
 
 	dd->full_url = g_strdup_printf("http://%s:%d",
-			descriptionAddress, port);
-	g_free(descriptionAddress);
+		purple_http_url_get_host(url),
+		purple_http_url_get_port(url));
+	purple_http_url_free(url);
 
 	/* Remove the timeout because everything it is waiting for has
 	 * successfully completed */
@@ -702,25 +697,19 @@
 		gpointer cb_data)
 {
 	PurpleUtilFetchUrlData* gfud;
+	PurpleHttpURL *url;
 	gchar* soapMessage;
 	gchar* totalSendMessage;
-	gchar* pathOfControl;
-	gchar* addressOfControl;
-	int port = 0;
 
-	/* parse the url into address, port, path variables */
-	if(!purple_url_parse(control_info.control_url, &addressOfControl,
-			&port, &pathOfControl, NULL, NULL)) {
-		purple_debug_error("upnp",
-			"generate_action_message_and_send(): Failed In Parse URL\n");
+	url = purple_http_url_parse(control_info.control_url);
+	if (!url) {
+		purple_debug_error("upnp", "generate_action_message_and_send():"
+			" Failed In Parse URL\n");
 		/* XXX: This should probably be async */
 		if(cb)
 			cb(NULL, cb_data, NULL, 0, NULL);
 		return NULL;
 	}
-	if(port == 0 || port == -1) {
-		port = DEFAULT_HTTP_PORT;
-	}
 
 	/* set the soap message */
 	soapMessage = g_strdup_printf(SOAP_ACTION, actionName,
@@ -728,17 +717,18 @@
 
 	/* set the HTTP Header, and append the body to it */
 	totalSendMessage = g_strdup_printf(HTTP_HEADER_ACTION "%s",
-		pathOfControl, addressOfControl, port,
+		purple_http_url_get_path(url),
+		purple_http_url_get_host(url),
+		purple_http_url_get_port(url),
 		control_info.service_type, actionName,
 		strlen(soapMessage), soapMessage);
-	g_free(pathOfControl);
 	g_free(soapMessage);
 
 	gfud = purple_util_fetch_url_request(NULL, control_info.control_url, FALSE, NULL, TRUE,
 				totalSendMessage, TRUE, MAX_UPNP_DOWNLOAD, cb, cb_data);
 
 	g_free(totalSendMessage);
-	g_free(addressOfControl);
+	purple_http_url_free(url);
 
 	return gfud;
 }
@@ -835,27 +825,26 @@
 static void
 lookup_internal_ip()
 {
-	gchar* addressOfControl;
-	int port = 0;
+	PurpleHttpURL *url;
 
-	if(!purple_url_parse(control_info.control_url, &addressOfControl, &port,
-			NULL, NULL, NULL)) {
+	url = purple_http_url_parse(control_info.control_url);
+	if (!url) {
 		purple_debug_error("upnp",
 			"lookup_internal_ip(): Failed In Parse URL\n");
 		return;
 	}
-	if(port == 0 || port == -1) {
-		port = DEFAULT_HTTP_PORT;
+
+	if(purple_proxy_connect(NULL, NULL, purple_http_url_get_host(url),
+		purple_http_url_get_port(url), looked_up_internal_ip_cb,
+		NULL) == NULL)
+	{
+		purple_debug_error("upnp", "Get Local IP Connect Failed: "
+			"Address: %s @@@ Port %d\n",
+			purple_http_url_get_host(url),
+			purple_http_url_get_port(url));
 	}
 
-	if(purple_proxy_connect(NULL, NULL, addressOfControl, port,
-			looked_up_internal_ip_cb, NULL) == NULL)
-	{
-		purple_debug_error("upnp", "Get Local IP Connect Failed: Address: %s @@@ Port %d\n",
-			addressOfControl, port);
-	}
-
-	g_free(addressOfControl);
+	purple_http_url_free(url);
 }
 
 static void

mercurial