changeset 23929:48da97d84886

Don't arbitrarily default font settings when none are specified for incoming Bonjour messages. Thanks to Simon Wenner for noticing and figuring out why this was happening. Fixes #6601
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 28 Aug 2008 04:12:31 +0000
parents 18f6ff443104
children e9eb71dc21af
files libpurple/protocols/bonjour/jabber.c
diffstat 1 files changed, 18 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/jabber.c	Thu Aug 28 01:55:39 2008 +0000
+++ b/libpurple/protocols/bonjour/jabber.c	Thu Aug 28 04:12:31 2008 +0000
@@ -171,19 +171,13 @@
 		html_body_node = xmlnode_get_child(html_node, "body");
 		if (html_body_node != NULL) {
 			xmlnode *html_body_font_node;
-			const char *ichat_balloon_color = NULL;
-			const char *ichat_text_color = NULL;
-			const char *font_face = NULL;
-			const char *font_size = NULL;
-			const char *font_color = NULL;
 
-			ichat_balloon_color = xmlnode_get_attrib(html_body_node, "ichatballooncolor");
-			ichat_text_color = xmlnode_get_attrib(html_body_node, "ichattextcolor");
 			html_body_font_node = xmlnode_get_child(html_body_node, "font");
-
 			/* Types of messages sent by iChat */
 			if (html_body_font_node != NULL) {
 				gchar *html_body;
+				const char *font_face, *font_size, *font_color,
+					*ichat_balloon_color, *ichat_text_color;
 
 				font_face = xmlnode_get_attrib(html_body_font_node, "face");
 				/* The absolute iChat font sizes should be converted to 1..7 range */
@@ -191,22 +185,29 @@
 				if (font_size != NULL)
 					font_size = _font_size_ichat_to_purple(atoi(font_size));
 				font_color = xmlnode_get_attrib(html_body_font_node, "color");
+				ichat_balloon_color = xmlnode_get_attrib(html_body_node, "ichatballooncolor");
+				ichat_text_color = xmlnode_get_attrib(html_body_node, "ichattextcolor");
+
 				html_body = get_xmlnode_contents(html_body_font_node);
 
 				if (html_body == NULL)
-					/* This is the kind of formated messages that Purple creates */
+					/* This is the kind of formatted messages that Purple creates */
 					html_body = xmlnode_to_str(html_body_font_node, NULL);
 
 				if (html_body != NULL) {
-					/* Use some sane defaults */
-					if (font_face == NULL) font_face = "Helvetica";
-					if (font_size == NULL) font_size = "3";
-					if (ichat_text_color == NULL) ichat_text_color = "#000000";
-					if (ichat_balloon_color == NULL) ichat_balloon_color = "#FFFFFF";
+					GString *str = g_string_new("<font");
 
-					body = g_strdup_printf("<font face='%s' size='%s' color='%s' back='%s'>%s</font>",
-								   font_face, font_size, ichat_text_color, ichat_balloon_color,
-								   html_body);
+					if (font_face)
+						g_string_append_printf(str, " face='%s'", font_face);
+					if (font_size)
+						g_string_append_printf(str, " size='%s'", font_size);
+					if (ichat_text_color)
+						g_string_append_printf(str, " color='%s'", ichat_text_color);
+					if (ichat_balloon_color)
+						g_string_append_printf(str, " back='%s'", ichat_balloon_color);
+					g_string_append_printf(str, ">%s</font>", html_body);
+
+					body = g_string_free(str, FALSE);
 
 					g_free(html_body);
 				}