changeset 25097:43055addf135

Grab only the "short" hostname on systems (like Fedora/RedHat, but others too) which put the FQDN in the hostname. Fixes #8419. committer: John Bailey <rekkanoryo@rekkanoryo.org>
author mcepl@redhat.com
date Sun, 15 Feb 2009 20:22:30 +0000
parents a3e3c6331e06
children 9bd43d30d49a
files ChangeLog libpurple/protocols/jabber/jabber.c
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Feb 15 19:01:58 2009 +0000
+++ b/ChangeLog	Sun Feb 15 20:22:30 2009 +0000
@@ -7,6 +7,9 @@
 	  enable, check the "Use SSL" option from the Advanced tab when
 	  editing your AIM or ICQ account. (Paul Aurich)
 	* Fix a memory leak in SILC. (Luke Petre)
+	* XMPP resources using __HOSTNAME__ substitution will now grab only the
+	  short hostname instead of the FQDN on systems which put the FQDN in
+	  the hostname (Matěj Cepl)
 
 	ICQ:
 	* Fix retrieval of status messages from users of ICQ 6.x, Miranda, and
--- a/libpurple/protocols/jabber/jabber.c	Sun Feb 15 19:01:58 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sun Feb 15 20:22:30 2009 +0000
@@ -148,7 +148,8 @@
 }
 
 static char *jabber_prep_resource(char *input) {
-	char hostname[256]; /* current hostname */
+	char hostname[256], /* current hostname */
+		 *dot = NULL;
 
 	/* Empty resource == don't send any */
 	if (input == NULL || *input == '\0')
@@ -170,6 +171,12 @@
 	}
 	hostname[sizeof(hostname) - 1] = '\0';
 
+	/* We want only the short hostname, not the FQDN - this will prevent the
+	 * resource string from being unreasonably long on systems which stuff the
+	 * whole FQDN in the hostname */
+	if((dot = strchr(hostname, '.')))
+			dot = '\0';
+
 	return purple_strreplace(input, "__HOSTNAME__", hostname);
 }