Mercurial > pidgin.yaz
changeset 27532:04d8452dee48
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?
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 10 Jul 2009 18:41:56 +0000 |
parents | 1b580473e753 |
children | 3599729ce9ce |
files | libpurple/protocols/jabber/jutil.c |
diffstat | 1 files changed, 13 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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;