# HG changeset patch # User Mark Doliner # Date 1247251316 0 # Node ID 04d8452dee48da89965ab8896d6bb06777f76701 # Parent 1b580473e7533a9aa4f31c7a084581fe3d1ee9da Change jabber_id_new() to iterate byte by byte instead of character by character. This should be safe because the 2nd, 3rd and 4th bytes of a multibyte utf8 character cannot also be a valid character in the ASCII alphabet... right? diff -r 1b580473e753 -r 04d8452dee48 libpurple/protocols/jabber/jutil.c --- a/libpurple/protocols/jabber/jutil.c Fri Jul 10 06:37:13 2009 +0000 +++ b/libpurple/protocols/jabber/jutil.c Fri Jul 10 18:41:56 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;