# HG changeset patch # User Ethan Blanton # Date 1080668680 0 # Node ID 2f505651ac03cdc20fd8157a2a66d288557af91b # Parent a48da599fd75b83557ff7b45f8a5b3a531bda8b7 [gaim-migrate @ 9268] This strips mIRC color and formatting codes from topics and provides a generic function for stripping mirc color codes and returning plain text (irc_mirc2txt()). This should fix Bug #923672. committer: Tailor Script diff -r a48da599fd75 -r 2f505651ac03 src/protocols/irc/irc.h --- a/src/protocols/irc/irc.h Tue Mar 30 15:45:52 2004 +0000 +++ b/src/protocols/irc/irc.h Tue Mar 30 17:44:40 2004 +0000 @@ -84,6 +84,7 @@ gboolean irc_blist_timeout(struct irc_conn *irc); char *irc_mirc2html(const char *string); +char *irc_mirc2txt(const char *string); void irc_msg_table_build(struct irc_conn *irc); void irc_parse_msg(struct irc_conn *irc, char *input); diff -r a48da599fd75 -r 2f505651ac03 src/protocols/irc/msgs.c --- a/src/protocols/irc/msgs.c Tue Mar 30 15:45:52 2004 +0000 +++ b/src/protocols/irc/msgs.c Tue Mar 30 17:44:40 2004 +0000 @@ -260,10 +260,10 @@ if (!strcmp(name, "topic")) { chan = args[0]; - topic = args[1]; + topic = irc_mirc2txt (args[1]); } else { chan = args[1]; - topic = args[2]; + topic = irc_mirc2txt (args[2]); } convo = gaim_find_conversation_with_account(chan, irc->account); @@ -285,6 +285,7 @@ g_free(msg); } g_free(tmp); + g_free(topic); } void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args) diff -r a48da599fd75 -r 2f505651ac03 src/protocols/irc/parse.c --- a/src/protocols/irc/parse.c Tue Mar 30 15:45:52 2004 +0000 +++ b/src/protocols/irc/parse.c Tue Mar 30 17:44:40 2004 +0000 @@ -35,8 +35,6 @@ static char *irc_send_convert(struct irc_conn *irc, const char *string); static char *irc_recv_convert(struct irc_conn *irc, const char *string); -char *irc_mirc2html(const char *string); - static void irc_parse_error_cb(struct irc_conn *irc, char *input); static char *irc_mirc_colors[16] = { @@ -269,6 +267,28 @@ return g_string_free(decoded, FALSE); } +char *irc_mirc2txt (const char *string) +{ + char *result = g_strdup (string); + int i, j; + + for (i = 0, j = 0; result[i]; i++) { + switch (result[i]) { + case '\002': + case '\003': + case '\007': + case '\017': + case '\026': + case '\037': + continue; + default: + result[j++] = result[i]; + } + } + result[i] = '\0'; + return result; +} + char *irc_parse_ctcp(struct irc_conn *irc, const char *from, const char *to, const char *msg, int notice) { GaimConnection *gc;