changeset 28729:4ab6f0479bc5

strchr() is safe when searching for an ASCII character in UTF8 strings.
author Paul Aurich <paul@darkrain42.org>
date Tue, 01 Dec 2009 16:46:57 +0000
parents 6ebacc1710b2
children 3d471a4bafac
files libpurple/protocols/jabber/buddy.c libpurple/protocols/jabber/chat.c libpurple/protocols/jabber/presence.c
diffstat 3 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c	Tue Dec 01 04:56:47 2009 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Tue Dec 01 16:46:57 2009 +0000
@@ -1860,8 +1860,10 @@
 	 * However, since the gateway might appear offline to us, we cannot get that information. Therefore, I just assume
 	 * that gateways on the roster can be identified by having no '@' in their jid. This is a faily safe assumption, since
 	 * people don't tend to have a server or other service there.
+	 *
+	 * TODO: Use disco#info...
 	 */
-	if (g_utf8_strchr(name, -1, '@') == NULL) {
+	if (strchr(name, '@') == NULL) {
 		act = purple_menu_action_new(_("Log In"),
 									 PURPLE_CALLBACK(jabber_buddy_login),
 									 NULL, NULL);
--- a/libpurple/protocols/jabber/chat.c	Tue Dec 01 04:56:47 2009 +0000
+++ b/libpurple/protocols/jabber/chat.c	Tue Dec 01 16:46:57 2009 +0000
@@ -927,7 +927,7 @@
 	jcm = g_hash_table_lookup(chat->members, who);
 	if (jcm && jcm->jid)
 		jid = jcm->jid;
-	else if (g_utf8_strchr(who, -1, '@') != NULL)
+	else if (strchr(who, '@') != NULL)
 		jid = who;
 	else
 		return FALSE;
@@ -964,7 +964,7 @@
 	jcm = g_hash_table_lookup(chat->members, who);
 	if (jcm && jcm->jid)
 		jid = jcm->jid;
-	else if (g_utf8_strchr(who, -1, '@') != NULL)
+	else if (strchr(who, '@') != NULL)
 		jid = who;
 	else
 		return FALSE;
--- a/libpurple/protocols/jabber/presence.c	Tue Dec 01 04:56:47 2009 +0000
+++ b/libpurple/protocols/jabber/presence.c	Tue Dec 01 16:46:57 2009 +0000
@@ -433,7 +433,7 @@
                                  JabberPresenceCapabilities *userdata)
 {
 	JabberBuddyResource *jbr;
-	char *resource = g_utf8_strchr(userdata->from, -1, '/');
+	char *resource = strchr(userdata->from, '/');
 
 	if (resource)
 		resource += 1;