im.pidgin.pidgin: 38186c8ce748007fdb4d2eefedee6f3642a9af90

nosnilmot at pidgin.im nosnilmot at pidgin.im
Tue Feb 26 09:00:38 EST 2008


-----------------------------------------------------------------
Revision: 38186c8ce748007fdb4d2eefedee6f3642a9af90
Ancestor: bd8310274d1042fdb2ed736b385293ff134ddee0
Author: nosnilmot at pidgin.im
Date: 2008-02-26T13:53:22
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/38186c8ce748007fdb4d2eefedee6f3642a9af90

Modified files:
        ChangeLog.API libpurple/protocols/jabber/jabber.c
        libpurple/util.c libpurple/util.h

ChangeLog: 

Use connect server as FQDN for SASL auth except when it is an IP address.
References #699.

-------------- next part --------------
============================================================
--- ChangeLog.API	1dc8f076568168e6c6d0ffbcbf924d4578002392
+++ ChangeLog.API	56e199b808a79c88afaf4c40319b066d6626bd94
@@ -9,6 +9,7 @@ version 2.4.0 (??/??/????):
 		  purple_micro_version variables are exported by version.h,
 		  giving the version of libpurple in use at runtime.
 		* purple_util_set_current_song, purple_util_format_song_info
+		* purple_ip_address_is_valid
 		* Some accessor functions to the Roomlist API:
 			* purple_roomlist_get_fields
 			* purple_roomlist_room_get_type
============================================================
--- libpurple/protocols/jabber/jabber.c	adf0280fc2a535cd4b4bf37cd04a0e9e8c558c16
+++ libpurple/protocols/jabber/jabber.c	987be3a39eb1ec8f0abd966ad6a31b37a6928a13
@@ -564,9 +564,16 @@ static void tls_init(JabberStream *js)
 			jabber_login_callback_ssl, jabber_ssl_connect_failure, js->certificate_CN, js->gc);
 }
 
-static void jabber_login_connect(JabberStream *js, const char *fqdn, const char *host, int port)
+static void jabber_login_connect(JabberStream *js, const char *domain, const char *host, int port)
 {
-	js->serverFQDN = g_strdup(fqdn);
+	/* host should be used in preference to domain to
+	 * allow SASL authentication to work with FQDN of the server,
+	 * but we use domain as fallback for when users enter IP address
+	 * in connect server */
+	if (purple_ip_address_is_valid(host))
+		js->serverFQDN = g_strdup(domain);
+	else
+		js->serverFQDN = g_strdup(host);
 
 	if (purple_proxy_connect(js->gc, js->gc->account, host,
 			port, jabber_login_callback, js->gc) == NULL)
============================================================
--- libpurple/util.c	1b362c0534b084dde914314ee50a1e392bd3e763
+++ libpurple/util.c	d13cc8319912ac1e9a79b8026579c2a8112cde0e
@@ -4129,6 +4129,17 @@ purple_email_is_valid(const char *addres
 	return ((c - domain) > 3 ? TRUE : FALSE);
 }
 
+gboolean
+purple_ip_address_is_valid(const char *ip)
+{
+	int c, o1, o2, o3, o4;
+	char end;
+	c = sscanf(ip, "%d.%d.%d.%d%c", &o1, &o2, &o3, &o4, &end);
+	if (c > 4 || o1 < 0 || o1 > 255 || o2 < 0 || o2 > 255 || o3 < 0 || o3 > 255 || o4 < 0 || o4 > 255)
+		return FALSE;
+	return TRUE;
+}
+
 /* Stolen from gnome_uri_list_extract_uris */
 GList *
 purple_uri_list_extract_uris(const gchar *uri_list)
============================================================
--- libpurple/util.h	55564322be9c4ef39a3dce010516ee0bc1b3668c
+++ libpurple/util.h	db0023d54848b660ea1c1f277158299c4baba549
@@ -1081,6 +1081,15 @@ gboolean purple_email_is_valid(const cha
 gboolean purple_email_is_valid(const char *address);
 
 /**
+ * Checks if the given IP address is a syntactically valid IPv4 address.
+ *
+ * @param address The IP address to validate.
+ *
+ * @return True if the IP address is syntactically correct.
+ */
+gboolean purple_ip_address_is_valid(const char *ip);
+
+/**
  * This function extracts a list of URIs from the a "text/uri-list"
  * string.  It was "borrowed" from gnome_uri_list_extract_uris
  *


More information about the Commits mailing list