changeset 27539:167d7c3a4f7b

XMPP allows for internationalized domain names. We don't actually support IDNA for connecting (AFAIK), but we need to be able to receive stanzas from such users. This check might be overly accepting of some non-ASCII that wouldn't properly convert according to RFC3490. See http://xmpp.org/internet-drafts/draft-ietf-xmpp-3920bis-00.html#addressing-domain and http://tools.ietf.org/html/rfc3490
author Paul Aurich <paul@darkrain42.org>
date Sat, 11 Jul 2009 00:49:25 +0000
parents 2eba2794423d
children da3d0159333d
files libpurple/protocols/jabber/jutil.c libpurple/tests/test_jabber_jutil.c
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jutil.c	Sat Jul 11 00:05:43 2009 +0000
+++ b/libpurple/protocols/jabber/jutil.c	Sat Jul 11 00:49:25 2009 +0000
@@ -73,11 +73,11 @@
 	while(c && *c) {
 		gunichar ch = g_utf8_get_char(c);
 		/* The list of characters allowed in domain names is pretty small */
-		if (!( (ch >= 'a' && ch <= 'z')
+		if ((ch <= 0x7F && !( (ch >= 'a' && ch <= 'z')
 				|| (ch >= '0' && ch <= '9')
 				|| (ch >= 'A' && ch <= 'Z')
 				|| ch == '.'
-				|| ch == '-' ))
+				|| ch == '-' )) || (ch >= 0x80 && !g_unichar_isgraph(ch)))
 			return FALSE;
 
 		c = g_utf8_next_char(c);
--- a/libpurple/tests/test_jabber_jutil.c	Sat Jul 11 00:05:43 2009 +0000
+++ b/libpurple/tests/test_jabber_jutil.c	Sat Jul 11 00:49:25 2009 +0000
@@ -95,6 +95,10 @@
 	assert_valid_jid("まりるーむ@conference.jabber.org");
 	assert_valid_jid("mark.doliner@gmail.com/まりるーむ");
 	assert_valid_jid("mark.doliner@gmail/stuff.org");
+	assert_valid_jid("stuart@nödåtXäYZ.se");
+	assert_valid_jid("stuart@nödåtXäYZ.se/まりるーむ");
+	assert_valid_jid("mark.doliner@わいど.org");
+	assert_valid_jid("nick@まつ.おおかみ.net");
 
 	assert_invalid_jid("@gmail.com");
 	assert_invalid_jid("@@gmail.com");
@@ -107,7 +111,6 @@
 	assert_invalid_jid("mark.doliner@gmail_stuff.org");
 	assert_invalid_jid("mark.doliner@gmail[stuff.org");
 	assert_invalid_jid("mark.doliner@gmail\\stuff.org");
-	assert_invalid_jid("mark.doliner@わいど.org");
 }
 END_TEST