pidgin: 5f34ca8e: jabber: Reject invalid chat nicks in /ni..
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Fri Oct 23 21:45:45 EDT 2009
-----------------------------------------------------------------
Revision: 5f34ca8ecb9f3ed36f1b66300ecfd2197e0e8243
Ancestor: 3e58009fdf3794f608eb605e745deabe1ec4d9aa
Author: darkrain42 at pidgin.im
Date: 2009-10-24T00:59:12
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/5f34ca8ecb9f3ed36f1b66300ecfd2197e0e8243
Modified files:
libpurple/protocols/jabber/chat.c
libpurple/protocols/jabber/chat.h
libpurple/protocols/jabber/jabber.c
ChangeLog:
jabber: Reject invalid chat nicks in /nick command. Fixes #10532.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/chat.c f7fc22e20ebc600fe5b0d4e41b27bcadc2e716ea
+++ libpurple/protocols/jabber/chat.c 3a68552f9a26fb9143fca11f2b3293d4d97ec776
@@ -692,11 +692,11 @@ void jabber_chat_set_topic(PurpleConnect
}
-void jabber_chat_change_nick(JabberChat *chat, const char *nick)
+gboolean jabber_chat_change_nick(JabberChat *chat, const char *nick)
{
xmlnode *presence;
char *full_jid;
- PurplePresence *gpresence;
+ PurpleAccount *account;
PurpleStatus *status;
JabberBuddyState state;
char *msg;
@@ -706,11 +706,11 @@ void jabber_chat_change_nick(JabberChat
purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "",
_("Nick changing not supported in non-MUC chatrooms"),
PURPLE_MESSAGE_SYSTEM, time(NULL));
- return;
+ return FALSE;
}
- gpresence = purple_account_get_presence(chat->js->gc->account);
- status = purple_presence_get_active_status(gpresence);
+ account = purple_connection_get_account(chat->js->gc);
+ status = purple_account_get_active_status(account);
purple_status_to_jabber(status, &state, &msg, &priority);
@@ -722,6 +722,8 @@ void jabber_chat_change_nick(JabberChat
jabber_send(chat->js, presence);
xmlnode_free(presence);
+
+ return TRUE;
}
void jabber_chat_part(JabberChat *chat, const char *msg)
============================================================
--- libpurple/protocols/jabber/chat.h fe8301dfd06b6335f245538f6796b527c0eeaf04
+++ libpurple/protocols/jabber/chat.h cbe69a6aac3a5bb37feb2e194260390909ea98ca
@@ -89,7 +89,7 @@ void jabber_chat_set_topic(PurpleConnect
void jabber_chat_register(JabberChat *chat);
void jabber_chat_change_topic(JabberChat *chat, const char *topic);
void jabber_chat_set_topic(PurpleConnection *gc, int id, const char *topic);
-void jabber_chat_change_nick(JabberChat *chat, const char *nick);
+gboolean jabber_chat_change_nick(JabberChat *chat, const char *nick);
void jabber_chat_part(JabberChat *chat, const char *msg);
void jabber_chat_track_handle(JabberChat *chat, const char *handle,
const char *jid, const char *affiliation, const char *role);
============================================================
--- libpurple/protocols/jabber/jabber.c a945522f767322b112cdb5ebdf75e0e05de9228d
+++ libpurple/protocols/jabber/jabber.c fce4f939b80d703b58cc4db9ca9f2f1af90819fa
@@ -2606,8 +2606,15 @@ static PurpleCmdRet jabber_cmd_chat_nick
if(!chat || !args || !args[0])
return PURPLE_CMD_RET_FAILED;
- jabber_chat_change_nick(chat, args[0]);
- return PURPLE_CMD_RET_OK;
+ if (!jabber_resourceprep_validate(args[0])) {
+ *error = g_strdup(_("Invalid nickname"));
+ return PURPLE_CMD_RET_FAILED;
+ }
+
+ if (jabber_chat_change_nick(chat, args[0]))
+ return PURPLE_CMD_RET_OK;
+ else
+ return PURPLE_CMD_RET_FAILED;
}
static PurpleCmdRet jabber_cmd_chat_part(PurpleConversation *conv,
More information about the Commits
mailing list