pidgin: ff7369e1: Don't send a 'to' attribute on an outgoi...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Sun Feb 15 17:01:00 EST 2009


-----------------------------------------------------------------
Revision: ff7369e151932e20c318abd10759b3a18ef1e3de
Ancestor: a8298f36047255fb82e4fd453c6537d35b41fa77
Author: paul at darkrain42.org
Date: 2009-02-15T21:26:22
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/ff7369e151932e20c318abd10759b3a18ef1e3de

Modified files:
        ChangeLog libpurple/protocols/jabber/jabber.c

ChangeLog: 

Don't send a 'to' attribute on an outgoing stanza if we didn't receive one.
Fixes #6635, but there is another patch there that probably should be
considered.

-------------- next part --------------
============================================================
--- ChangeLog	fd1137b74db38212a509c9bc77fc795924f7570b
+++ ChangeLog	3dfbfc92379b2ae4854716d416ba5a8f80cd50d2
@@ -12,6 +12,9 @@ version 2.5.5 (??/??/????):
 	  the hostname (Mat?j Cepl)
 	* Fix some string handling in the SIMPLE prpl, which fixes some buddy name
 	  handling and other issues. (Paul Aurich, Marcus Sundberg)
+	* No longer send a 'to' attribute on an outgoing XMPP stanza when we
+	  haven't received one.  This fixes a registration bug as described in
+	  ticket #6635.
 
 	ICQ:
 	* Fix retrieval of status messages from users of ICQ 6.x, Miranda, and
============================================================
--- libpurple/protocols/jabber/jabber.c	ba28e4ae155263bc56f22f3327529df9f71ebff1
+++ libpurple/protocols/jabber/jabber.c	ffa2b86a187b53e8e165af133466d0a7e5251046
@@ -809,10 +809,11 @@ jabber_registration_result_cb(JabberStre
 				js->user->node, js->user->domain);
 			if(account->registration_cb)
 				(account->registration_cb)(account, TRUE, account->registration_cb_user_data);
-		}
-		else
+		} else {
+			g_return_if_fail(to != NULL);
 			buf = g_strdup_printf(_("Registration to %s successful"),
 				to);
+		}
 		purple_notify_info(NULL, _("Registration Successful"),
 				_("Registration Successful"), buf);
 		g_free(buf);
@@ -839,7 +840,11 @@ jabber_unregistration_result_cb(JabberSt
 	const char *type = xmlnode_get_attrib(packet, "type");
 	char *buf;
 	char *to = data;
-	
+
+	/* This function is never called for unregistering our XMPP account from
+	 * the server, so there should always be a 'to' address. */
+	g_return_if_fail(to != NULL);
+
 	if(!strcmp(type, "result")) {
 		buf = g_strdup_printf(_("Registration from %s successfully removed"),
 							  to);
@@ -874,7 +879,8 @@ jabber_register_cb(JabberRegisterCBData 
 
 	iq = jabber_iq_new_query(cbdata->js, JABBER_IQ_SET, "jabber:iq:register");
 	query = xmlnode_get_child(iq->node, "query");
-	xmlnode_set_attrib(iq->node, "to", cbdata->who);
+	if (cbdata->who)
+		xmlnode_set_attrib(iq->node, "to", cbdata->who);
 
 	for(groups = purple_request_fields_get_groups(fields); groups;
 			groups = groups->next) {
@@ -890,7 +896,8 @@ jabber_register_cb(JabberRegisterCBData 
 					jabber_iq_free(iq);
 					iq = jabber_iq_new_query(cbdata->js, JABBER_IQ_SET, "jabber:iq:register");
 					query = xmlnode_get_child(iq->node, "query");
-					xmlnode_set_attrib(iq->node,"to",cbdata->who);
+					if (cbdata->who)
+						xmlnode_set_attrib(iq->node,"to",cbdata->who);
 					xmlnode_new_child(query, "remove");
 					
 					jabber_iq_set_callback(iq, jabber_unregistration_result_cb, cbdata->who);
@@ -935,8 +942,7 @@ jabber_register_cb(JabberRegisterCBData 
 			}
 			xmlnode_insert_data(y, value, -1);
 				if(cbdata->js->registration && !strcmp(id, "username")) {
-					if(cbdata->js->user->node)
-						g_free(cbdata->js->user->node);
+					g_free(cbdata->js->user->node);
 					cbdata->js->user->node = g_strdup(value);
 			}
 				if(cbdata->js->registration && !strcmp(id, "password"))
@@ -979,7 +985,8 @@ static void jabber_register_x_data_cb(Ja
 
 	iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
 	query = xmlnode_get_child(iq->node, "query");
-	xmlnode_set_attrib(iq->node,"to",to);
+	if (to)
+		xmlnode_set_attrib(iq->node,"to",to);
 
 	xmlnode_insert_child(query, result);
 
@@ -1004,10 +1011,7 @@ void jabber_register_parse(JabberStream 
 		return;
 
 	from = xmlnode_get_attrib(packet, "from");
-	if (!from)
-		from = js->serverFQDN;
-	g_return_if_fail(from != NULL);
-	
+
 	if(js->registration) {
 		/* get rid of the login thingy */
 		purple_connection_set_state(js->gc, PURPLE_CONNECTED);
@@ -1152,7 +1156,9 @@ void jabber_register_parse(JabberStream 
 				purple_connection_get_account(js->gc), NULL, NULL,
 				cbdata);
 	else {
-		char *title = registered?g_strdup_printf(_("Change Account Registration at %s"), from)
+		char *title;
+		g_return_if_fail(from != NULL);
+		title = registered ? g_strdup_printf(_("Change Account Registration at %s"), from)
 								:g_strdup_printf(_("Register New Account at %s"), from);
 		purple_request_fields(js->gc, title,
 			  title, instructions, fields,


More information about the Commits mailing list