changeset 27458:048550ab13a4

merge of 'c79c76ef54b9b6ee38720172c7cc655dcee22893' and 'ce52a4af6787aad5221596cca9b17c86441bad96'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 10 Jul 2009 19:29:49 +0000
parents 07d09a987b86 (current diff) 3599729ce9ce (diff)
children 91fefa830798
files
diffstat 2 files changed, 21 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jutil.c	Fri Jul 10 15:18:09 2009 +0000
+++ b/libpurple/protocols/jabber/jutil.c	Fri Jul 10 19:29:49 2009 +0000
@@ -105,8 +105,7 @@
 {
 	const char *at = NULL;
 	const char *slash = NULL;
-	const char *cur;
-	gunichar c;
+	const char *c;
 	gboolean needs_validation = FALSE;
 #if 0
 	gboolean node_is_required = FALSE;
@@ -118,48 +117,47 @@
 	if (!str)
 		return NULL;
 
-	for (cur = str; *cur != '\0'; cur = g_utf8_next_char(cur))
+	for (c = str; *c != '\0'; c++)
 	{
-		c = g_utf8_get_char(cur);
-		switch (c) {
+		switch (*c) {
 			case '@':
 				if (!slash) {
 					if (at) {
 						/* Multiple @'s in the node/domain portion, not a valid JID! */
 						return NULL;
 					}
-					if (cur == str) {
+					if (c == str) {
 						/* JIDs cannot start with @ */
 						return NULL;
 					}
-					if ((g_utf8_next_char(cur))[0] == '\0') {
+					if (c[1] == '\0') {
 						/* JIDs cannot end with @ */
 						return NULL;
 					}
-					at = cur;
+					at = c;
 				}
 				break;
 
 			case '/':
 				if (!slash) {
-					if (cur == str) {
+					if (c == str) {
 						/* JIDs cannot start with / */
 						return NULL;
 					}
-					if ((g_utf8_next_char(cur))[0] == '\0') {
+					if (c[1] == '\0') {
 						/* JIDs cannot end with / */
 						return NULL;
 					}
-					slash = cur;
+					slash = c;
 				}
 				break;
 
 			default:
 				/* characters allowed everywhere */
-				if ((c > 'a' && c < 'z')
-						|| (c > '0' && c < '9')
-						|| (c > 'A' && c < 'Z')
-						|| c == '.' || c == '-')
+				if ((*c > 'a' && *c < 'z')
+						|| (*c > '0' && *c < '9')
+						|| (*c > 'A' && *c < 'Z')
+						|| *c == '.' || *c == '-')
 					/* We're good */
 					break;
 
--- a/libpurple/tests/test_jabber_jutil.c	Fri Jul 10 15:18:09 2009 +0000
+++ b/libpurple/tests/test_jabber_jutil.c	Fri Jul 10 19:29:49 2009 +0000
@@ -91,6 +91,9 @@
 	assert_valid_jid("mark.doliner@gmail.com/Test12345");
 	assert_valid_jid("mark.doliner@gmail.com/Test@12345");
 	assert_valid_jid("mark.doliner@gmail.com/Te/st@12@//345");
+	assert_valid_jid("わいど@conference.jabber.org");
+	assert_valid_jid("まりるーむ@conference.jabber.org");
+	assert_valid_jid("mark.doliner@gmail.com/まりるーむ");
 
 	assert_invalid_jid("@gmail.com");
 	assert_invalid_jid("@@gmail.com");
@@ -100,6 +103,11 @@
 	assert_invalid_jid("/Test@12345");
 	assert_invalid_jid("mark.doliner@");
 	assert_invalid_jid("mark.doliner/");
+	assert_valid_jid("mark.doliner@gmail_stuff.org");
+	assert_valid_jid("mark.doliner@gmail[stuff.org");
+	assert_valid_jid("mark.doliner@gmail/stuff.org");
+	assert_valid_jid("mark.doliner@gmail\\stuff.org");
+	assert_valid_jid("mark.doliner@わいど.org");
 }
 END_TEST