# HG changeset patch # User Paul Aurich # Date 1247277467 0 # Node ID 302934aea9fb68d21eedd8e0d6728624ce32a3aa # Parent e52a7c4e9cbb635f61dea77c8111f72168275ef6# Parent da3d0159333deb689739927f7a2cf5be7c4588f5 merge of '10c77c853c49f28524dabf8a5149818138c09c60' and '7bc0b08014d8d13ff8ee8c61c280e4d963b578d2' diff -r e52a7c4e9cbb -r 302934aea9fb libpurple/protocols/jabber/jutil.c --- a/libpurple/protocols/jabber/jutil.c Sat Jul 11 01:24:50 2009 +0000 +++ b/libpurple/protocols/jabber/jutil.c Sat Jul 11 01:57:47 2009 +0000 @@ -65,19 +65,18 @@ return FALSE; /* - * This should be more similar to purple_email_is_valid(). Maybe - * that function should even be split up and we should call the part - * that validates the domain name. + * TODO: An IPv6 address of the form [2001:470:1f05:d58::2] is also + * a valid XMPP domain portion. */ c = str; 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); diff -r e52a7c4e9cbb -r 302934aea9fb libpurple/protocols/jabber/jutil.h --- a/libpurple/protocols/jabber/jutil.h Sat Jul 11 01:24:50 2009 +0000 +++ b/libpurple/protocols/jabber/jutil.h Sat Jul 11 01:57:47 2009 +0000 @@ -45,6 +45,7 @@ gboolean jabber_is_own_account(JabberStream *js, const char *jid); gboolean jabber_nodeprep_validate(const char *); +/* TODO: This needs to be named jabber_domain_validate and handle IPv6/IDNA. */ gboolean jabber_nameprep_validate(const char *); gboolean jabber_resourceprep_validate(const char *); diff -r e52a7c4e9cbb -r 302934aea9fb libpurple/tests/test_jabber_jutil.c --- a/libpurple/tests/test_jabber_jutil.c Sat Jul 11 01:24:50 2009 +0000 +++ b/libpurple/tests/test_jabber_jutil.c Sat Jul 11 01:57:47 2009 +0000 @@ -95,6 +95,16 @@ 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_valid_jid("paul@10.0.42.230/s"); +#if 0 +/* Uncomment these when jabber_domain_validate supports IPv6 addresses */ + assert_valid_jid("paul@[::1]"); /* IPv6 */ + assert_valid_jid("paul@[2001:470:1f05:d58::2]"); +#endif assert_invalid_jid("@gmail.com"); assert_invalid_jid("@@gmail.com"); @@ -107,7 +117,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