im.pidgin.pidgin: 6b57335241f2c9a501643280407bdc3374100dee

rekkanoryo at cpw.pidgin.im rekkanoryo at cpw.pidgin.im
Sat Oct 6 18:05:55 EDT 2007


revision:            6b57335241f2c9a501643280407bdc3374100dee
date:                2007-10-06T21:58:54
author:              rekkanoryo at cpw.pidgin.im
branch:              im.pidgin.pidgin
changelog:
Fix the mIRC format handling bug that causes incorrect display of received
text.  The behavior of g_markup_escape_text changed in glib 2.12, which
caused this bug.  This fix copies the working version of said function and
the private helper function append_escaped_text() into our IRC prpl.

Fixes #3467

manifest:
format_version "1"

new_manifest [7f2cc431cd18cd2118b7307602be710bf39dbfcb]

old_revision [6c08c628ee64e16c824829c25befc0ca09338f9d]

patch "libpurple/protocols/irc/irc.h"
 from [02e49573abff5bb446f90d894279b179f17c9409]
   to [902fb8f09c5da6aaf12d0bfe6bd0db208dcdd93a]

patch "libpurple/protocols/irc/msgs.c"
 from [f622c12f00969dee5584d531367433501d203d11]
   to [2ae4e09fd8a5dea0a214f3871cceb4e3dd63a529]

patch "libpurple/protocols/irc/parse.c"
 from [1c8c93675ef3a48f0f86ed3415727d83154cd766]
   to [8cfa3826a61d754377c5f4a2878f5df0255b4605]
-------------- next part --------------
============================================================
--- libpurple/protocols/irc/irc.h	02e49573abff5bb446f90d894279b179f17c9409
+++ libpurple/protocols/irc/irc.h	902fb8f09c5da6aaf12d0bfe6bd0db208dcdd93a
@@ -99,6 +99,8 @@ gboolean irc_blist_timeout(struct irc_co
 int irc_send(struct irc_conn *irc, const char *buf);
 gboolean irc_blist_timeout(struct irc_conn *irc);
 
+char *irc_escape_privmsg(const char *text, gssize length);
+
 char *irc_mirc2html(const char *string);
 char *irc_mirc2txt(const char *string);
 
============================================================
--- libpurple/protocols/irc/msgs.c	f622c12f00969dee5584d531367433501d203d11
+++ libpurple/protocols/irc/msgs.c	2ae4e09fd8a5dea0a214f3871cceb4e3dd63a529
@@ -1066,7 +1066,7 @@ static void irc_msg_handle_privmsg(struc
 		return;
 	}
 
-	msg = g_markup_escape_text(tmp, -1);
+	msg = irc_escape_privmsg(tmp, -1);
 	g_free(tmp);
 
 	tmp = irc_mirc2html(msg);
============================================================
--- libpurple/protocols/irc/parse.c	1c8c93675ef3a48f0f86ed3415727d83154cd766
+++ libpurple/protocols/irc/parse.c	8cfa3826a61d754377c5f4a2878f5df0255b4605
@@ -281,6 +281,61 @@ static char *irc_recv_convert(struct irc
 	return purple_utf8_salvage(string);
 }
 
+/* This function is shamelessly stolen from glib--it is an old version of the
+ * private function append_escaped_text, used by g_markup_escape_text, whose
+ * behavior changed in glib 2.12. */
+static void irc_append_escaped_text(GString *str, const char *text, gssize length)
+{
+	const char *p = text;
+	const char *end = text + length;
+	const char *next = NULL;
+
+	while(p != end) {
+		next = g_utf8_next_char(p);
+
+		switch(*p) {
+			case '&':
+				g_string_append(str, "&");
+				break;
+			case '<':
+				g_string_append(str, "&lt;");
+				break;
+			case '>':
+				g_string_append(str, "&gt;");
+				break;
+			case '\'':
+				g_string_append(str, "&apos;");
+				break;
+			case '"':
+				g_string_append(str, "&quot;");
+				break;
+			default:
+				g_string_append_len(str, p, next - p);
+				break;
+		}
+
+		p = next;
+	}
+}
+
+/* This function is shamelessly stolen from glib--it is an old version of the
+ * function g_markup_escape_text, whose behavior changed in glib 2.12. */
+char *irc_escape_privmsg(const char *text, gssize length)
+{
+	GString *str;
+
+	g_return_val_if_fail(text != NULL, NULL);
+
+	if(length < 0)
+		length = strlen(text);
+
+	str = g_string_sized_new(length);
+
+	irc_append_escaped_text(str, text, length);
+
+	return g_string_free(str, FALSE);
+}
+
 /* XXX tag closings are not necessarily correctly nested here!  If we
  *     get a ^O or reach the end of the string and there are open
  *     tags, they are closed in a fixed order ... this means, for


More information about the Commits mailing list