gaim/gaim

66d138574a08
Parents 5e68afa16f47
Children 589958e0b0e2
Bunch'o'escaping for IRC on oldstatus. I should save up all this escaping
for when I really need to get away from somewhere.
--- a/src/protocols/irc/msgs.c Sat Apr 02 21:01:51 2005 -0500
+++ b/src/protocols/irc/msgs.c Sat Apr 02 21:04:36 2005 -0500
@@ -76,6 +76,7 @@
void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args)
{
GaimConnection *gc;
+ char *msg;
if (!args || !args[1])
return;
@@ -87,8 +88,11 @@
}
gc = gaim_account_get_connection(irc->account);
- if (gc)
- serv_got_im(gc, args[1], args[2], GAIM_CONV_IM_AUTO_RESP, time(NULL));
+ if (gc) {
+ msg = g_markup_escape_text(args[2], -1);
+ serv_got_im(gc, args[1], msg, GAIM_CONV_IM_AUTO_RESP, time(NULL));
+ g_free(msg);
+ }
}
void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args)
@@ -138,7 +142,7 @@
void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args)
{
GaimConversation *convo;
- char *buf;
+ char *buf, *escaped;
if (!args || !args[1] || !args[2])
return;
@@ -147,8 +151,10 @@
if (!convo) /* XXX punt on channels we are not in for now */
return;
- buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], args[3] ? args[3] : "");
+ escaped = (args[3] != NULL) ? g_markup_escape_text(args[3], -1) : NULL;
+ buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], escaped ? escaped : "");
gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
+ g_free(escaped);
g_free(buf);
return;
@@ -328,13 +334,15 @@
void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args)
{
GaimConnection *gc = gaim_account_get_connection(irc->account);
- char *buf;
+ char *buf, *escaped;
if (!args || !args[1] || !gc)
return;
- buf = g_strdup_printf(_("Unknown message '%s'"), args[1]);
+ escaped = g_markup_escape_text(args[1], -1);
+ buf = g_strdup_printf(_("Unknown message '%s'"), escaped);
gaim_notify_error(gc, _("Unknown message"), buf, _("Gaim has sent a message the IRC server did not understand."));
+ g_free(escaped);
g_free(buf);
}
@@ -416,6 +424,7 @@
void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args)
{
GaimConnection *gc;
+ char *escaped;
if (!strcmp(name, "375")) {
gc = gaim_account_get_connection(irc->account);
if (gc)
@@ -425,7 +434,9 @@
if (!irc->motd)
irc->motd = g_string_new("");
- g_string_append_printf(irc->motd, "%s<br>", args[1]);
+ escaped = g_markup_escape_text(args[1], -1);
+ g_string_append_printf(irc->motd, "%s<br>", escaped);
+ g_free(escaped);
}
void irc_msg_endmotd(struct irc_conn *irc, const char *name, const char *from, char **args)
@@ -447,24 +458,30 @@
void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args)
{
GaimConnection *gc;
+ char *time;
gc = gaim_account_get_connection(irc->account);
if (gc == NULL || args == NULL || args[2] == NULL)
return;
+ time = g_markup_escape_text(args[2], -1);
gaim_notify_message(gc, GAIM_NOTIFY_MSG_INFO, _("Time Response"),
_("The IRC server's local time is:"),
- args[2], NULL, NULL);
+ time, NULL, NULL);
+ g_free(time);
}
void irc_msg_nochan(struct irc_conn *irc, const char *name, const char *from, char **args)
{
GaimConnection *gc = gaim_account_get_connection(irc->account);
+ char *escaped;
if (gc == NULL || args == NULL || args[1] == NULL)
return;
- gaim_notify_error(gc, NULL, _("No such channel"), args[1]);
+ escaped = g_markup_escape_text(args[1], -1);
+ gaim_notify_error(gc, NULL, _("No such channel"), escaped);
+ g_free(escaped);
}
void irc_msg_nonick(struct irc_conn *irc, const char *name, const char *from, char **args)
@@ -652,7 +669,7 @@
{
GaimConnection *gc = gaim_account_get_connection(irc->account);
GaimConversation *convo = gaim_find_conversation_with_account(args[0], irc->account);
- char *nick = irc_mask_nick(from), *buf;
+ char *nick = irc_mask_nick(from), *buf, *reason;
if (!gc) {
g_free(nick);
@@ -665,17 +682,19 @@
return;
}
+ reason = g_markup_escape_text(args[2], -1);
if (!gaim_utf8_strcasecmp(gaim_connection_get_display_name(gc), args[1])) {
- buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]);
+ buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, reason);
gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], buf, GAIM_MESSAGE_SYSTEM, time(NULL));
g_free(buf);
serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)));
} else {
- buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]);
+ buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, reason);
gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo), args[1], buf);
g_free(buf);
}
+ g_free(reason);
g_free(nick);
return;
}
@@ -686,14 +705,17 @@
char *nick = irc_mask_nick(from), *buf;
if (*args[0] == '#' || *args[0] == '&') { /* Channel */
+ char *escaped;
convo = gaim_find_conversation_with_account(args[0], irc->account);
if (!convo) {
gaim_debug(GAIM_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]);
g_free(nick);
return;
}
- buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], args[2] ? args[2] : "", nick);
+ escaped = (args[2] != NULL) ? g_markup_escape_text(args[2], -1) : NULL;
+ buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick);
gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
+ g_free(escaped);
g_free(buf);
if(args[2]) {
GaimConvChatBuddyFlags newflag, flags;
@@ -827,8 +849,8 @@
if (!args || !args[2] || !gc)
return;
- msg = g_strdup_printf(_("Could not change nick"));
- gaim_notify_error(gc, _("Cannot change nick"), msg, args[2]);
+ msg = g_markup_escape_text(args[2], -1);
+ gaim_notify_error(gc, _("Cannot change nick"), _("Could not change nick"), msg);
g_free(msg);
}
@@ -964,14 +986,16 @@
void irc_msg_regonly(struct irc_conn *irc, const char *name, const char *from, char **args)
{
GaimConnection *gc = gaim_account_get_connection(irc->account);
- char *msg;
+ char *msg, *reason;
if (!args || !args[1] || !args[2] || !gc)
return;
msg = g_strdup_printf(_("Cannot join %s:"), args[1]);
- gaim_notify_error(gc, _("Cannot join channel"), msg, args[2]);
+ reason = g_markup_escape_text(args[2], -1);
+ gaim_notify_error(gc, _("Cannot join channel"), msg, reason);
g_free(msg);
+ g_free(reason);
}
void irc_msg_quit(struct irc_conn *irc, const char *name, const char *from, char **args)