pidgin: 949fb996: Fix an issue with formatting in Bonjour ...

datallah at pidgin.im datallah at pidgin.im
Wed Apr 16 22:50:43 EDT 2008


-----------------------------------------------------------------
Revision: 949fb9967a8d4bcae83af4ebc6b2681f26b17f5a
Ancestor: 7b8c78270e8505ab07661388a27be78911fe2856
Author: datallah at pidgin.im
Date: 2008-04-17T02:45:37
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/949fb9967a8d4bcae83af4ebc6b2681f26b17f5a

Modified files:
        libpurple/protocols/bonjour/jabber.c

ChangeLog: 

Fix an issue with formatting in Bonjour messages.  It looks like it has been
broken for a long time. Fixes #5518.

-------------- next part --------------
============================================================
--- libpurple/protocols/bonjour/jabber.c	b8f26aae93cbbe9456b4f47cbc52b19e57d35173
+++ libpurple/protocols/bonjour/jabber.c	8f59d1a97da79b07ba34324f4cb25d00f8f43250
@@ -114,6 +114,28 @@ _font_size_ichat_to_purple(int size)
 	return "1";
 }
 
+static gchar *
+get_xmlnode_contents(xmlnode *node)
+{
+	gchar *contents;
+
+	contents = xmlnode_to_str(node, NULL);
+
+	/* we just want the stuff inside <font></font>
+	 * There isn't stuff exposed in xmlnode.c to do this more cleanly. */
+
+	if (contents) {
+		char *bodystart = strchr(contents, '>');
+		char *bodyend = strrchr(bodystart, '<');
+		if (bodystart && bodyend && (bodystart + 1) != bodyend) {
+			*bodyend = '\0';
+			memmove(contents, bodystart + 1, (bodyend - bodystart));
+		}
+	}
+
+	return contents;
+}
+
 static void
 _jabber_parse_and_write_message_to_ui(xmlnode *message_node, PurpleBuddy *pb)
 {
@@ -167,7 +189,7 @@ _jabber_parse_and_write_message_to_ui(xm
 				if (font_size != NULL)
 					font_size = _font_size_ichat_to_purple(atoi(font_size));
 				font_color = xmlnode_get_attrib(html_body_font_node, "color");
-				html_body = xmlnode_get_data(html_body_font_node);
+				html_body = get_xmlnode_contents(html_body_font_node);
 
 				if (html_body == NULL)
 					/* This is the kind of formated messages that Purple creates */


More information about the Commits mailing list