changeset 27750:1b440a47dc04

Change Yahoo to send <span> tags with a color style attribute instead of <font> tags, which are deprecated in recent versions of html
author Mark Doliner <mark@kingant.net>
date Fri, 31 Jul 2009 01:28:41 +0000
parents 1b5b24dc0310
children 58f29c0286fe
files libpurple/protocols/yahoo/util.c libpurple/tests/test_yahoo_util.c
diffstat 2 files changed, 32 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/util.c	Fri Jul 31 01:06:42 2009 +0000
+++ b/libpurple/protocols/yahoo/util.c	Fri Jul 31 01:28:41 2009 +0000
@@ -215,16 +215,16 @@
 
 	ht = g_hash_table_new(g_str_hash, g_str_equal);
 	/* the numbers in comments are what gyach uses, but i think they're incorrect */
-	g_hash_table_insert(ht, "30", "<font color=\"#000000\">"); /* black */
-	g_hash_table_insert(ht, "31", "<font color=\"#0000FF\">"); /* blue */
-	g_hash_table_insert(ht, "32", "<font color=\"#008080\">"); /* cyan */      /* 00b2b2 */
-	g_hash_table_insert(ht, "33", "<font color=\"#808080\">"); /* gray */      /* 808080 */
-	g_hash_table_insert(ht, "34", "<font color=\"#008000\">"); /* green */     /* 00c200 */
-	g_hash_table_insert(ht, "35", "<font color=\"#FF0080\">"); /* pink */      /* ffafaf */
-	g_hash_table_insert(ht, "36", "<font color=\"#800080\">"); /* purple */    /* b200b2 */
-	g_hash_table_insert(ht, "37", "<font color=\"#FF8000\">"); /* orange */    /* ffff00 */
-	g_hash_table_insert(ht, "38", "<font color=\"#FF0000\">"); /* red */
-	g_hash_table_insert(ht, "39", "<font color=\"#808000\">"); /* olive */     /* 546b50 */
+	g_hash_table_insert(ht, "30", "<span style=\"color: #000000\">"); /* black */
+	g_hash_table_insert(ht, "31", "<span style=\"color: #0000FF\">"); /* blue */
+	g_hash_table_insert(ht, "32", "<span style=\"color: #008080\">"); /* cyan */      /* 00b2b2 */
+	g_hash_table_insert(ht, "33", "<span style=\"color: #808080\">"); /* gray */      /* 808080 */
+	g_hash_table_insert(ht, "34", "<span style=\"color: #008000\">"); /* green */     /* 00c200 */
+	g_hash_table_insert(ht, "35", "<span style=\"color: #FF0080\">"); /* pink */      /* ffafaf */
+	g_hash_table_insert(ht, "36", "<span style=\"color: #800080\">"); /* purple */    /* b200b2 */
+	g_hash_table_insert(ht, "37", "<span style=\"color: #FF8000\">"); /* orange */    /* ffff00 */
+	g_hash_table_insert(ht, "38", "<span style=\"color: #FF0000\">"); /* red */
+	g_hash_table_insert(ht, "39", "<span style=\"color: #808000\">"); /* olive */     /* 546b50 */
 
 	g_hash_table_insert(ht,  "1",  "<b>");
 	g_hash_table_insert(ht, "x1", "</b>");
@@ -240,27 +240,27 @@
 	g_hash_table_insert(ht, "l", ""); /* link start */
 	g_hash_table_insert(ht, "xl", ""); /* link end */
 
-	g_hash_table_insert(ht, "<black>",  "<font color=\"#000000\">");
-	g_hash_table_insert(ht, "<blue>",   "<font color=\"#0000FF\">");
-	g_hash_table_insert(ht, "<cyan>",   "<font color=\"#008284\">");
-	g_hash_table_insert(ht, "<gray>",   "<font color=\"#848284\">");
-	g_hash_table_insert(ht, "<green>",  "<font color=\"#008200\">");
-	g_hash_table_insert(ht, "<pink>",   "<font color=\"#FF0084\">");
-	g_hash_table_insert(ht, "<purple>", "<font color=\"#840084\">");
-	g_hash_table_insert(ht, "<orange>", "<font color=\"#FF8000\">");
-	g_hash_table_insert(ht, "<red>",    "<font color=\"#FF0000\">");
-	g_hash_table_insert(ht, "<yellow>", "<font color=\"#848200\">");
+	g_hash_table_insert(ht, "<black>",  "<span style=\"color: #000000\">");
+	g_hash_table_insert(ht, "<blue>",   "<span style=\"color: #0000FF\">");
+	g_hash_table_insert(ht, "<cyan>",   "<span style=\"color: #008284\">");
+	g_hash_table_insert(ht, "<gray>",   "<span style=\"color: #848284\">");
+	g_hash_table_insert(ht, "<green>",  "<span style=\"color: #008200\">");
+	g_hash_table_insert(ht, "<pink>",   "<span style=\"color: #FF0084\">");
+	g_hash_table_insert(ht, "<purple>", "<span style=\"color: #840084\">");
+	g_hash_table_insert(ht, "<orange>", "<span style=\"color: #FF8000\">");
+	g_hash_table_insert(ht, "<red>",    "<span style=\"color: #FF0000\">");
+	g_hash_table_insert(ht, "<yellow>", "<span style=\"color: #848200\">");
 
-	g_hash_table_insert(ht, "</black>",  "</font>");
-	g_hash_table_insert(ht, "</blue>",   "</font>");
-	g_hash_table_insert(ht, "</cyan>",   "</font>");
-	g_hash_table_insert(ht, "</gray>",   "</font>");
-	g_hash_table_insert(ht, "</green>",  "</font>");
-	g_hash_table_insert(ht, "</pink>",   "</font>");
-	g_hash_table_insert(ht, "</purple>", "</font>");
-	g_hash_table_insert(ht, "</orange>", "</font>");
-	g_hash_table_insert(ht, "</red>",    "</font>");
-	g_hash_table_insert(ht, "</yellow>", "</font>");
+	g_hash_table_insert(ht, "</black>",  "</span>");
+	g_hash_table_insert(ht, "</blue>",   "</span>");
+	g_hash_table_insert(ht, "</cyan>",   "</span>");
+	g_hash_table_insert(ht, "</gray>",   "</span>");
+	g_hash_table_insert(ht, "</green>",  "</span>");
+	g_hash_table_insert(ht, "</pink>",   "</span>");
+	g_hash_table_insert(ht, "</purple>", "</span>");
+	g_hash_table_insert(ht, "</orange>", "</span>");
+	g_hash_table_insert(ht, "</red>",    "</span>");
+	g_hash_table_insert(ht, "</yellow>", "</span>");
 
 	/* remove these once we have proper support for <FADE> and <ALT> */
 	g_hash_table_insert(ht, "</fade>", "");
@@ -354,7 +354,7 @@
 				else {
 					tmp = g_string_new_len(x + i + 2, j - i - 2);
 					if (tmp->str[0] == '#')
-						g_string_append_printf(s, "<font color=\"%s\">", tmp->str);
+						g_string_append_printf(s, "<span style=\"color: %s\">", tmp->str);
 					else if ((match = (char *) g_hash_table_lookup(ht, tmp->str)))
 						g_string_append(s, match);
 					else {
--- a/libpurple/tests/test_yahoo_util.c	Fri Jul 31 01:06:42 2009 +0000
+++ b/libpurple/tests/test_yahoo_util.c	Fri Jul 31 01:28:41 2009 +0000
@@ -20,6 +20,7 @@
 	assert_string_equal_free("<i>italic", yahoo_codes_to_html("\x1B[2mitalic"));
 	assert_string_equal_free("<u>underline", yahoo_codes_to_html("\x1B[4munderline"));
 	assert_string_equal_free("<b>bold</b> <i>italic</i> <u>underline", yahoo_codes_to_html("\x1B[1mbold\x1B[x1m \x1B[2mitalic\x1B[x2m \x1B[4munderline"));
+	assert_string_equal_free("<span style=\"color: #0000FF\">blue", yahoo_codes_to_html("\x1B[31mblue"));
 }
 END_TEST