pidgin: 620db212: strchr() is safe when searching for an A...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Tue Dec 1 16:20:43 EST 2009


-----------------------------------------------------------------
Revision: 620db212c4a7d3e8ab6d192ef0c3ae5abfd764a0
Ancestor: 5c0b873fe3c22c45d708e6455514edac31619055
Author: darkrain42 at pidgin.im
Date: 2009-12-01T16:46:57
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/620db212c4a7d3e8ab6d192ef0c3ae5abfd764a0

Modified files:
        libpurple/protocols/jabber/buddy.c
        libpurple/protocols/jabber/chat.c
        libpurple/protocols/jabber/presence.c

ChangeLog: 

strchr() is safe when searching for an ASCII character in UTF8 strings.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/buddy.c	04bc7984bb02176cfd7fbf99dc3b00e27d50ff8f
+++ libpurple/protocols/jabber/buddy.c	09b7cddd837736c60e809ed53d987d9886a07e53
@@ -1860,8 +1860,10 @@ static GList *jabber_buddy_menu(PurpleBu
 	 * 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);
============================================================
--- libpurple/protocols/jabber/chat.c	131d1890de69d77be2338ce3c03e2041c87e7b4d
+++ libpurple/protocols/jabber/chat.c	1b2ee16110281b79806dbec67b5a1fdc45b4c9a6
@@ -927,7 +927,7 @@ gboolean jabber_chat_ban_user(JabberChat
 	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 @@ gboolean jabber_chat_affiliate_user(Jabb
 	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;
============================================================
--- libpurple/protocols/jabber/presence.c	be29edcccb6572456e13bbcb692624fd8765fe8e
+++ libpurple/protocols/jabber/presence.c	5e221c074ca59e7ddb536c0f8c9f7e18f479a980
@@ -433,7 +433,7 @@ jabber_presence_set_capabilities(JabberC
                                  JabberPresenceCapabilities *userdata)
 {
 	JabberBuddyResource *jbr;
-	char *resource = g_utf8_strchr(userdata->from, -1, '/');
+	char *resource = strchr(userdata->from, '/');
 
 	if (resource)
 		resource += 1;


More information about the Commits mailing list