pidgin.2.5.7: dae8e022: Backport a conjunction of the portions o...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Fri Jun 19 17:40:51 EDT 2009


-----------------------------------------------------------------
Revision: dae8e0225a1317c83d9be0e34f9ef97f65833e3b
Ancestor: 85b7401615acafde6e25abdfe4fa536d8db7fb99
Author: rekkanoryo at pidgin.im
Date: 2009-06-19T01:07:51
Branch: im.pidgin.pidgin.2.5.7
URL: http://d.pidgin.im/viewmtn/revision/info/dae8e0225a1317c83d9be0e34f9ef97f65833e3b

Modified files:
        libpurple/protocols/yahoo/yahoo.c
        libpurple/protocols/yahoo/yahoo.h

ChangeLog: 

Backport a conjunction of the portions of revisions
87f1558b52a3b5861b8e8f50ca0a04637b8c2102 and
b4506bcf7c69a70d3548ad9a804b2916534b48f7 that actually apply to this branch.

-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/yahoo.c	5eac78df860e361fab0cdad9a6579fecaec537f8
+++ libpurple/protocols/yahoo/yahoo.c	4a1d22ed350b8052bef019689c96af77897b286a
@@ -274,7 +274,7 @@ static void yahoo_process_status(PurpleC
 					f->status = YAHOO_STATUS_OFFLINE;
 				if (name) {
 					purple_prpl_got_user_status(account, name, "offline", NULL);
-			                purple_prpl_got_user_status_deactive(account, name, YAHOO_STATUS_TYPE_MOBILE);
+					purple_prpl_got_user_status_deactive(account, name, YAHOO_STATUS_TYPE_MOBILE);
 				}
 				break;
 			}
@@ -1392,8 +1392,8 @@ static void yahoo_auth16_stage3(PurpleCo
 
 	md5_cipher = purple_ciphers_find_cipher("md5");
 	md5_ctx = purple_cipher_context_new(md5_cipher, NULL);
-	purple_cipher_context_append(md5_ctx,(guchar *)crypt, strlen(crypt));
-	purple_cipher_context_digest(md5_ctx, sizeof(md5_digest),md5_digest, NULL);
+	purple_cipher_context_append(md5_ctx, (guchar *)crypt, strlen(crypt));
+	purple_cipher_context_digest(md5_ctx, sizeof(md5_digest), md5_digest, NULL);
 
 	to_y64(base64_string, md5_digest, 16);
 
@@ -1445,7 +1445,7 @@ static void yahoo_auth16_stage2(PurpleUt
 
 	g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc));
 
-	if (error_message != NULL)	{
+	if (error_message != NULL) {
 		purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message);
 		purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message);
 		g_free(auth_data->seed);
@@ -1455,21 +1455,21 @@ static void yahoo_auth16_stage2(PurpleUt
 	else if (len > 0 && ret_data && *ret_data) {
 		split_data = g_strsplit(ret_data, "\r\n", -1);
 		totalelements = g_strv_length(split_data);
-		if(totalelements >= 5)	{
-			response_no = strtol(*(split_data+1), NULL, 10);
-			crumb = g_strdup(*(split_data+2)+6);
-			yd->cookie_y = g_strdup(*(split_data+3)+2);
-			yd->cookie_t = g_strdup(*(split_data+4)+2);
+		if (totalelements >= 5) {
+			response_no = strtol(split_data[1], NULL, 10);
+			crumb = g_strdup(split_data[2] + 6);
+			yd->cookie_y = g_strdup(split_data[3] + 2);
+			yd->cookie_t = g_strdup(split_data[4] + 2);
 		}
 		else
 			response_no = -1;
 
 		g_strfreev(split_data);
 
-		if(response_no != 0)	{
+		if(response_no != 0) {
 			/* Some error in the login process */
 			PurpleConnectionError error;
-			switch(response_no)	{
+			switch(response_no) {
 				case -1:
 					/* Some error in the received stream */
 					error_reason = g_strdup(_("Error in the received data"));
@@ -1482,7 +1482,7 @@ static void yahoo_auth16_stage2(PurpleUt
 					break;
 				default:
 					/* if we have everything we need, why not try to login irrespective of response */
-					if((crumb != NULL) && (yd->cookie_y != NULL) && (yd->cookie_t != NULL))	{
+					if((crumb != NULL) && (yd->cookie_y != NULL) && (yd->cookie_t != NULL)) {
 						try_login_on_error = TRUE;
 						break;
 					}
@@ -1490,13 +1490,13 @@ static void yahoo_auth16_stage2(PurpleUt
 					error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
 					break;
 			}
-			if(error_reason)	{
+			if(error_reason) {
 				purple_debug_error("yahoo","Authentication error: %s", error_reason);
 				purple_connection_error_reason(gc, error, error_reason);
 				g_free(error_reason);
 			}
 		}
-		if((response_no == 0) || try_login_on_error)	{
+		if((response_no == 0) || try_login_on_error) {
 			crypt = g_strconcat(crumb, auth_data->seed, NULL);
 			yahoo_auth16_stage3(gc, crypt);
 			g_free(crumb);
@@ -1521,7 +1521,7 @@ static void yahoo_auth16_stage1_cb(Purpl
 
 	g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc));
 
-	if (error_message != NULL)	{
+	if (error_message != NULL) {
 		purple_debug_error("yahoo", "Login Failed, unable to retrieve login url: %s\n", error_message);
 		purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message);
 		g_free(auth_data->seed);
@@ -1532,19 +1532,19 @@ static void yahoo_auth16_stage1_cb(Purpl
 		split_data = g_strsplit(ret_data, "\r\n", -1);
 		totalelements = g_strv_length(split_data);
 		
-		if(totalelements >= 5)	{
-			response_no = strtol(*(split_data+1), NULL, 10);
-			token = g_strdup(*(split_data+2)+6);
+		if(totalelements >= 5) {
+			response_no = strtol(split_data[1], NULL, 10);
+			token = g_strdup(split_data[2] + 6);
 		}
 		else
 			response_no = -1;
 
 		g_strfreev(split_data);
 
-		if(response_no != 0)	{
+		if(response_no != 0) {
 			/* Some error in the login process */
 			PurpleConnectionError error;
-			switch(response_no)	{
+			switch(response_no) {
 				case -1:
 					/* Some error in the received stream */
 					error_reason = g_strdup(_("Error in the received data"));
@@ -1593,10 +1593,7 @@ static void yahoo_auth16_stage1_cb(Purpl
 			gboolean yahoojp = purple_account_get_bool(purple_connection_get_account(gc),
 				"yahoojp", 0);
 
-			url = g_strdup_printf(yahoojp ?
-					"https://login.yahoo.co.jp/config/pwtoken_login?src=ymsgr&ts=&token=%s" : 
-					"https://login.yahoo.com/config/pwtoken_login?src=ymsgr&ts=&token=%s",
-					token);
+			url = g_strdup_printf(yahoojp ? YAHOOJP_LOGIN_URL : YAHOO_LOGIN_URL, token);
 			url_data2 = purple_util_fetch_url_request(url, TRUE, "Mozilla/4.0 (compatible; MSIE 5.5)", TRUE, NULL, FALSE, yahoo_auth16_stage2, auth_data);
 			g_free(url);
 			g_free(token);
@@ -1609,6 +1606,8 @@ static void yahoo_auth16_stage1(PurpleCo
 	PurpleUtilFetchUrlData *url_data = NULL;
 	struct yahoo_auth_data *auth_data = NULL;
 	char *url = NULL;
+	char *encoded_username;
+	char *encoded_password;
 	gboolean yahoojp;
 
 	purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage1\n");
@@ -1624,11 +1623,12 @@ static void yahoo_auth16_stage1(PurpleCo
 	auth_data->gc = gc;
 	auth_data->seed = g_strdup(seed);
 
-	url = g_strdup_printf(yahoojp ?
-			"https://login.yahoo.co.jp/config/pwtoken_get?src=ymsgr&ts=&login=%s&passwd=%s&chal=%s" :
-			"https://login.yahoo.com/config/pwtoken_get?src=ymsgr&ts=&login=%s&passwd=%s&chal=%s",
-			purple_account_get_username(purple_connection_get_account(gc)),
-			purple_connection_get_password(gc), seed);
+	encoded_username = g_strdup(purple_url_encode(purple_account_get_username(purple_connection_get_account(gc))));
+	encoded_password = g_strdup(purple_url_encode(purple_connection_get_password(gc)));
+	url = g_strdup_printf(yahoojp ? YAHOOJP_TOKEN_URL : YAHOO_TOKEN_URL,
+			encoded_username, encoded_password, purple_url_encode(seed));
+	g_free(encoded_password);
+	g_free(encoded_username);
 
 	url_data = purple_util_fetch_url_request(url, TRUE, "Mozilla/4.0 (compatible; MSIE 5.5)", TRUE, NULL, FALSE, yahoo_auth16_stage1_cb, auth_data);
 	g_free(url);
@@ -2378,7 +2378,7 @@ static void yahoo_web_pending(gpointer d
 		i += strlen("Set-Cookie: ");
 		for (;*i != ';' && *i != '\0'; i++)
 			g_string_append_c(s, *i);
-        
+
 		g_string_append(s, "; ");
 		/* Should these cookies be included too when trying for xfer?
 		 * It seems to work without these
============================================================
--- libpurple/protocols/yahoo/yahoo.h	ff1b084a6bb065d5c269847e1d5ec73a4b219432
+++ libpurple/protocols/yahoo/yahoo.h	f111e71b76816040a711839f084ca3ad19824fd5
@@ -30,6 +30,8 @@
 
 #define YAHOO_PAGER_HOST "scs.msg.yahoo.com"
 #define YAHOO_PAGER_PORT 5050
+#define YAHOO_LOGIN_URL "https://login.yahoo.com/config/pwtoken_login?src=ymsgr&ts=&token=%s"
+#define YAHOO_TOKEN_URL "https://login.yahoo.com/config/pwtoken_get?src=ymsgr&ts=&login=%s&passwd=%s&chal=%s"
 #define YAHOO_PROFILE_URL "http://profiles.yahoo.com/"
 #define YAHOO_MAIL_URL "https://login.yahoo.com/config/login?.src=ym"
 #define YAHOO_XFER_HOST "filetransfer.msg.yahoo.com"
@@ -41,6 +43,8 @@
 /* really we should get the list of servers from
  http://update.messenger.yahoo.co.jp/servers.html */
 #define YAHOOJP_PAGER_HOST "cs.yahoo.co.jp"
+#define YAHOOJP_TOKEN_URL "https://login.yahoo.co.jp/config/pwtoken_get?src=ymsgr&ts=&login=%s&passwd=%s&chal=%s"
+#define YAHOOJP_LOGIN_URL "https://login.yahoo.co.jp/config/pwtoken_login?src=ymsgr&ts=&token=%s"
 #define YAHOOJP_PROFILE_URL "http://profiles.yahoo.co.jp/"
 #define YAHOOJP_MAIL_URL "http://mail.yahoo.co.jp/"
 #define YAHOOJP_XFER_HOST "filetransfer.msg.yahoo.co.jp"


More information about the Commits mailing list