/cpw/tomkiewicz/http: 8bc333966d04: Revert changes to purple_url...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Tue Oct 16 06:06:51 EDT 2012


Changeset: 8bc333966d04aaebee934a8b1219e26992bc53ee
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2012-10-16 11:54 +0200
Branch:	 default
URL: http://hg.pidgin.im/cpw/tomkiewicz/http/rev/8bc333966d04

Description:

Revert changes to purple_url_parse, because no longer needed for new http implementation

diffstat:

 libpurple/obsolete.c                       |   4 +-
 libpurple/protocols/jabber/bosh.c          |   2 +-
 libpurple/protocols/jabber/oob.c           |   2 +-
 libpurple/protocols/msn/soap.c             |   2 +-
 libpurple/protocols/mxit/protocol.c        |   2 +-
 libpurple/protocols/yahoo/yahoo_aliases.c  |   6 +-
 libpurple/protocols/yahoo/yahoo_filexfer.c |   8 ++--
 libpurple/protocols/yahoo/yahoochat.c      |   4 +-
 libpurple/proxy.c                          |   2 +-
 libpurple/upnp.c                           |   6 +-
 libpurple/util.c                           |  48 ++++++++++++++++-------------
 libpurple/util.h                           |  18 +++++------
 12 files changed, 54 insertions(+), 50 deletions(-)

diffs (truncated from 316 to 300 lines):

diff --git a/libpurple/obsolete.c b/libpurple/obsolete.c
--- a/libpurple/obsolete.c
+++ b/libpurple/obsolete.c
@@ -170,7 +170,7 @@ parse_redirect(const char *data, size_t 
 	g_free(gfud->website.passwd);
 	g_free(gfud->website.address);
 	g_free(gfud->website.page);
-	purple_url_parse(new_url, NULL, &gfud->website.address, &gfud->website.port,
+	purple_url_parse(new_url, &gfud->website.address, &gfud->website.port,
 				   &gfud->website.page, &gfud->website.user, &gfud->website.passwd);
 
 	if (purple_strcasestr(new_url, "https://") != NULL) {
@@ -647,7 +647,7 @@ purple_util_fetch_url_request(PurpleAcco
 	gfud->max_len = max_len;
 	gfud->account = account;
 
-	purple_url_parse(url, NULL, &gfud->website.address, &gfud->website.port,
+	purple_url_parse(url, &gfud->website.address, &gfud->website.port,
 				   &gfud->website.page, &gfud->website.user, &gfud->website.passwd);
 
 	if (purple_strcasestr(url, "https://") != NULL) {
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
@@ -202,7 +202,7 @@ jabber_bosh_connection_init(JabberStream
 	char *host, *path, *user, *passwd;
 	int port;
 
-	if (!purple_url_parse(url, NULL, &host, &port, &path, &user, &passwd)) {
+	if (!purple_url_parse(url, &host, &port, &path, &user, &passwd)) {
 		purple_debug_info("jabber", "Unable to parse given URL.\n");
 		return NULL;
 	}
diff --git a/libpurple/protocols/jabber/oob.c b/libpurple/protocols/jabber/oob.c
--- a/libpurple/protocols/jabber/oob.c
+++ b/libpurple/protocols/jabber/oob.c
@@ -209,7 +209,7 @@ void jabber_oob_parse(JabberStream *js, 
 	url = xmlnode_get_data(urlnode);
 
 	jox = g_new0(JabberOOBXfer, 1);
-	if (!purple_url_parse(url, NULL, &jox->address, &jox->port, &jox->page, NULL, NULL)) {
+	if (!purple_url_parse(url, &jox->address, &jox->port, &jox->page, NULL, NULL)) {
 		g_free(url);
 		return;
 	}
diff --git a/libpurple/protocols/msn/soap.c b/libpurple/protocols/msn/soap.c
--- a/libpurple/protocols/msn/soap.c
+++ b/libpurple/protocols/msn/soap.c
@@ -274,7 +274,7 @@ msn_soap_handle_redirect(MsnSoapConnecti
 	char *host;
 	char *path;
 
-	if (purple_url_parse(url, NULL, &host, NULL, &path, NULL, NULL)) {
+	if (purple_url_parse(url, &host, NULL, &path, NULL, NULL)) {
 		MsnSoapRequest *req = conn->current_request;
 		conn->current_request = NULL;
 
diff --git a/libpurple/protocols/mxit/protocol.c b/libpurple/protocols/mxit/protocol.c
--- a/libpurple/protocols/mxit/protocol.c
+++ b/libpurple/protocols/mxit/protocol.c
@@ -337,7 +337,7 @@ static void mxit_write_http_post( struct
 	gboolean	ok;
 
 	/* extract the HTTP host name and host port number to connect to */
-	ok = purple_url_parse( session->http_server, NULL, &host_name, &host_port, NULL, NULL, NULL );
+	ok = purple_url_parse( session->http_server, &host_name, &host_port, NULL, NULL, NULL );
 	if ( !ok ) {
 		purple_debug_error( MXIT_PLUGIN_ID, "HTTP POST error: (host name '%s' not valid)\n", session->http_server );
 	}
diff --git a/libpurple/protocols/yahoo/yahoo_aliases.c b/libpurple/protocols/yahoo/yahoo_aliases.c
--- a/libpurple/protocols/yahoo/yahoo_aliases.c
+++ b/libpurple/protocols/yahoo/yahoo_aliases.c
@@ -197,7 +197,7 @@ yahoo_fetch_aliases(PurpleConnection *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, NULL, &webaddress, NULL, &webpage, NULL, NULL);
+	purple_url_parse(url, &webaddress, NULL, &webpage, NULL, 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"
@@ -321,7 +321,7 @@ yahoo_update_alias(PurpleConnection *gc,
 
 	/*  Build all the info to make the web request */
 	url = yd->jp ? YAHOOJP_ALIAS_UPDATE_URL: YAHOO_ALIAS_UPDATE_URL;
-	purple_url_parse(url, NULL, &webaddress, NULL, &webpage, NULL, NULL);
+	purple_url_parse(url, &webaddress, NULL, &webpage, NULL, NULL);
 
 	if (cb->id == NULL) {
 		/* No id for this buddy, so create an address book entry */
@@ -479,7 +479,7 @@ yahoo_set_userinfo_cb(PurpleConnection *
 
 	content = xmlnode_to_formatted_str(node, &len);
 	xmlnode_free(node);
-	purple_url_parse(yd->jp ? YAHOOJP_USERINFO_URL : YAHOO_USERINFO_URL, NULL, &webaddress, NULL, &webpage, NULL, NULL);
+	purple_url_parse(yd->jp ? YAHOOJP_USERINFO_URL : YAHOO_USERINFO_URL, &webaddress, NULL, &webpage, NULL, NULL);
 
 	request = g_strdup_printf("POST %s HTTP/1.1\r\n"
 				  "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
diff --git a/libpurple/protocols/yahoo/yahoo_filexfer.c b/libpurple/protocols/yahoo/yahoo_filexfer.c
--- a/libpurple/protocols/yahoo/yahoo_filexfer.c
+++ b/libpurple/protocols/yahoo/yahoo_filexfer.c
@@ -871,7 +871,7 @@ void yahoo_process_filetransfer(PurpleCo
 	/* 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, NULL, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL)) {
+	if (!purple_url_parse(url, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL)) {
 		g_free(xfer_data);
 		return;
 	}
@@ -1045,7 +1045,7 @@ static void yahoo_xfer_dns_connected_15(
 		hosts = g_slist_remove(hosts, hosts->data);
 	}
 
-	if (!purple_url_parse(url, NULL, &(xd->host), &(xd->port), &(xd->path), NULL, NULL)) {
+	if (!purple_url_parse(url, &(xd->host), &(xd->port), &(xd->path), NULL, NULL)) {
 		purple_xfer_cancel_remote(xfer);
 		g_free(url);
 		return;
@@ -1840,7 +1840,7 @@ void yahoo_process_filetrans_info_15(Pur
 	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, NULL, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL)) {
+		if (!purple_url_parse(url, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL)) {
 			purple_xfer_cancel_remote(xfer);
 			return;
 		}
@@ -1933,7 +1933,7 @@ void yahoo_process_filetrans_acc_15(Purp
 
 	xfer_data = purple_xfer_get_protocol_data(xfer);
 	if(url)
-		purple_url_parse(url, NULL, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL);
+		purple_url_parse(url, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL);
 
 	xfer_data->xfer_idstring_for_relay = g_strdup(xfer_idstring_for_relay);
 	xfer_data->status_15 = ACCEPTED;
diff --git a/libpurple/protocols/yahoo/yahoochat.c b/libpurple/protocols/yahoo/yahoochat.c
--- a/libpurple/protocols/yahoo/yahoochat.c
+++ b/libpurple/protocols/yahoo/yahoochat.c
@@ -1530,7 +1530,7 @@ PurpleRoomlist *yahoo_roomlist_get_list(
 	rl = purple_roomlist_new(account);
 	yrl->list = rl;
 
-	purple_url_parse(url, NULL, &(yrl->host), NULL, &(yrl->path), NULL, NULL);
+	purple_url_parse(url, &(yrl->host), NULL, &(yrl->path), NULL, NULL);
 	g_free(url);
 
 	f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", "room", TRUE);
@@ -1624,7 +1624,7 @@ void yahoo_roomlist_expand_category(Purp
 	proto_data = g_list_append(proto_data, yrl);
 	purple_roomlist_set_proto_data(list, proto_data);
 
-	purple_url_parse(url, NULL, &(yrl->host), NULL, &(yrl->path), NULL, NULL);
+	purple_url_parse(url, &(yrl->host), NULL, &(yrl->path), NULL, NULL);
 	g_free(url);
 
 	yrl->ucat = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_CATEGORY, _("User Rooms"), yrl->cat);
diff --git a/libpurple/proxy.c b/libpurple/proxy.c
--- a/libpurple/proxy.c
+++ b/libpurple/proxy.c
@@ -2278,7 +2278,7 @@ purple_proxy_get_setup(PurpleAccount *ac
 			/* http_proxy-format:
 			 * export http_proxy="http://user:passwd@your.proxy.server:port/"
 			 */
-			if(purple_url_parse(tmp, NULL, &proxyhost, &proxyport, NULL, &proxyuser, &proxypasswd)) {
+			if(purple_url_parse(tmp, &proxyhost, &proxyport, NULL, &proxyuser, &proxypasswd)) {
 				purple_proxy_info_set_host(gpi, proxyhost);
 				g_free(proxyhost);
 
diff --git a/libpurple/upnp.c b/libpurple/upnp.c
--- a/libpurple/upnp.c
+++ b/libpurple/upnp.c
@@ -438,7 +438,7 @@ purple_upnp_parse_description(const gcha
 	   example description URL: http://192.168.1.1:5678/rootDesc.xml */
 
 	/* parse the url into address, port, path variables */
-	if(!purple_url_parse(descriptionURL, NULL, &descriptionAddress,
+	if(!purple_url_parse(descriptionURL, &descriptionAddress,
 			&port, &descriptionXMLAddress, NULL, NULL)) {
 		return;
 	}
@@ -706,7 +706,7 @@ purple_upnp_generate_action_message_and_
 	int port = 0;
 
 	/* parse the url into address, port, path variables */
-	if(!purple_url_parse(control_info.control_url, NULL, &addressOfControl,
+	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");
@@ -837,7 +837,7 @@ lookup_internal_ip()
 	gchar* addressOfControl;
 	int port = 0;
 
-	if(!purple_url_parse(control_info.control_url, NULL, &addressOfControl, &port,
+	if(!purple_url_parse(control_info.control_url, &addressOfControl, &port,
 			NULL, NULL, NULL)) {
 		purple_debug_error("upnp",
 			"lookup_internal_ip(): Failed In Parse URL\n");
diff --git a/libpurple/util.c b/libpurple/util.c
--- a/libpurple/util.c
+++ b/libpurple/util.c
@@ -3859,20 +3859,31 @@ void purple_got_protocol_handler_uri(con
 		g_hash_table_destroy(params);
 }
 
+/*
+ * TODO: Should probably add a "gboolean *ret_ishttps" parameter that
+ *       is set to TRUE if this URL is https, otherwise it is set to
+ *       FALSE.  But that change will break the API.
+ *
+ *       This is important for Yahoo! web messenger login.  They now
+ *       force https login, and if you access the web messenger login
+ *       page via http then it redirects you to the https version, but
+ *       purple_util_fetch_url() ignores the "https" and attempts to
+ *       fetch the URL via http again, which gets redirected again.
+ */
 gboolean
-purple_url_parse(const char *url, char **ret_proto, char **ret_host,
-	int *ret_port, char **ret_path, char **ret_user, char **ret_passwd)
+purple_url_parse(const char *url, char **ret_host, int *ret_port,
+			   char **ret_path, char **ret_user, char **ret_passwd)
 {
 	gboolean is_https = FALSE;
 	const char * scan_info;
 	char port_str[6];
 	int f;
-	const char *at, *slash, *colon;
-	char proto[256], host[256], path[256], user[256], passwd[256];
+	const char *at, *slash;
+	const char *turl;
+	char host[256], path[256], user[256], passwd[256];
 	int port = 0;
 	/* hyphen at end includes it in control set */
 
-#define PROTO_CTRL "A-Za-z"
 #define ADDR_CTRL "A-Za-z0-9.-"
 #define PORT_CTRL "0-9"
 #define PAGE_CTRL "A-Za-z0-9.,~_/:*!@&%%?=+^-"
@@ -3880,22 +3891,18 @@ purple_url_parse(const char *url, char *
 #define PASSWD_CTRL "A-Za-z0-9.,~_/*!&%%?=+^-"
 
 	g_return_val_if_fail(url != NULL, FALSE);
-	g_return_val_if_fail(strlen(url) < 256, FALSE);
-
-	colon = strchr(url, ':');
-	if (colon) {
-		scan_info = "%255[" PROTO_CTRL "]:";
-		f = sscanf(url, scan_info, proto);
-
-		if (f == 1) {
-			url = colon + 1;
-			if (url[0] == '/') url++;
-			if (url[0] == '/') url++;
-		} else
-			proto[0] = '\0';
+
+	if ((turl = purple_strcasestr(url, "http://")) != NULL)
+	{
+		turl += 7;
+		url = turl;
 	}
-
-	is_https = (g_ascii_strcasecmp(proto, "https") == 0);
+	else if ((turl = purple_strcasestr(url, "https://")) != NULL)
+	{
+		is_https = TRUE;
+		turl += 8;
+		url = turl;
+	}
 
 	/* parse out authentication information if supplied */
 	/* Only care about @ char BEFORE the first / */
@@ -3943,7 +3950,6 @@ purple_url_parse(const char *url, char *
 
 	sscanf(port_str, "%d", &port);
 
-	if (ret_proto != NULL) *ret_proto = g_strdup(proto);
 	if (ret_host != NULL) *ret_host = g_strdup(host);
 	if (ret_port != NULL) *ret_port = port;
 	if (ret_path != NULL) *ret_path = g_strdup(path);
diff --git a/libpurple/util.h b/libpurple/util.h
--- a/libpurple/util.h
+++ b/libpurple/util.h
@@ -1144,21 +1144,19 @@ char *purple_str_binary_to_ascii(const u
 void purple_got_protocol_handler_uri(const char *uri);
 
 /**
- * Parses a URL, returning its protocol, host, port, file path, username and
- * password.
+ * 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_proto  The returned protocol.
- * @param ret_host   The returned host.
- * @param ret_port   The returned port.



More information about the Commits mailing list