changeset 17426:82a02dbf2fa2

This performs mIRC formatting code stripping for the room list, as well as fixing (I think) mIRC color code stripping for all purposes. I haven't tested this carefully, so someone scream if it breaks anything. Fixes #557
author Ethan Blanton <elb@pidgin.im>
date Mon, 28 May 2007 17:52:04 +0000
parents 58a286e231b7
children 7ada026a53b9 f7f4d11d4826
files libpurple/protocols/irc/msgs.c libpurple/protocols/irc/parse.c
diffstat 2 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/irc/msgs.c	Mon May 28 03:18:02 2007 +0000
+++ b/libpurple/protocols/irc/msgs.c	Mon May 28 17:52:04 2007 +0000
@@ -369,6 +369,7 @@
 
 	if (!strcmp(name, "322")) {
 		PurpleRoomlistRoom *room;
+		char *topic;
 
 		if (!args[0] || !args[1] || !args[2] || !args[3])
 			return;
@@ -376,7 +377,9 @@
 		room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, args[1], NULL);
 		purple_roomlist_room_add_field(irc->roomlist, room, args[1]);
 		purple_roomlist_room_add_field(irc->roomlist, room, GINT_TO_POINTER(strtol(args[2], NULL, 10)));
-		purple_roomlist_room_add_field(irc->roomlist, room, args[3]);
+		topic = irc_mirc2txt(args[3]);
+		purple_roomlist_room_add_field(irc->roomlist, room, topic);
+		g_free(topic);
 		purple_roomlist_room_add(irc->roomlist, room);
 	}
 }
--- a/libpurple/protocols/irc/parse.c	Mon May 28 03:18:02 2007 +0000
+++ b/libpurple/protocols/irc/parse.c	Mon May 28 17:52:04 2007 +0000
@@ -402,6 +402,22 @@
 		switch (result[i]) {
 		case '\002':
 		case '\003':
+			/* Foreground color */
+			if (isdigit(result[i + 1]))
+				i++;
+			if (isdigit(result[i + 1]))
+				i++;
+			/* Optional comma and background color */
+			if (result[i + 1] == ',') {
+				i++;
+				if (isdigit(result[i + 1]))
+					i++;
+				if (isdigit(result[i + 1]))
+					i++;
+			}
+			/* Note that i still points to the last character
+			 * of the color selection string. */
+			continue;
 		case '\007':
 		case '\017':
 		case '\026':