# HG changeset patch # User Paul Aurich # Date 1250841283 0 # Node ID adf7dc41770dbf7f2811a47f2133167d6a512cb9 # Parent d4847cef4a843bf3397d41ee1fc86958673e3339# Parent 4d4e6adea7bc7e6f411cecf391cb7cfe2e0d10a9 merge of '5ca4fe18a853bb7a6d9c45cd96ce2e9da4a2f8b8' and '888e6ea856a320f298628491af64116f42f6aec6' diff -r d4847cef4a84 -r adf7dc41770d libpurple/protocols/yahoo/util.c --- a/libpurple/protocols/yahoo/util.c Fri Aug 21 07:15:47 2009 +0000 +++ b/libpurple/protocols/yahoo/util.c Fri Aug 21 07:54:43 2009 +0000 @@ -712,6 +712,14 @@ g_string_append_printf(dest, "\033[%sm", attribute); *colors = g_slist_prepend(*colors, g_strdup_printf("\033[%sm", attribute)); + } else { + /* We need to add a value to the colors stack even if we're not + * setting a color because we ALWAYS pop exactly 1 element from + * this stack for every tag. If we don't add anything + * then we'll pop something that we shouldn't when we hit this + * corresponding . */ + *colors = g_slist_prepend(*colors, + *colors ? g_strdup((*colors)->data) : g_strdup("\033[#000000m")); } attribute = g_datalist_get_data(&attributes, "face"); @@ -868,11 +876,9 @@ char *etag = tags->data; tags = g_slist_delete_link(tags, tags); g_string_append(dest, etag); - if (g_str_equal(etag, "")) { - if (colors != NULL) { - g_free(colors->data); - colors = g_slist_delete_link(colors, colors); - } + if (colors != NULL) { + g_free(colors->data); + colors = g_slist_delete_link(colors, colors); } g_free(etag); } diff -r d4847cef4a84 -r adf7dc41770d libpurple/tests/test_yahoo_util.c --- a/libpurple/tests/test_yahoo_util.c Fri Aug 21 07:15:47 2009 +0000 +++ b/libpurple/tests/test_yahoo_util.c Fri Aug 21 07:54:43 2009 +0000 @@ -149,7 +149,7 @@ assert_string_equal_free("mark@example.com", yahoo_html_to_codes("mark@example.com")); #if 0 - assert_string_equal_free("http://pidgin.im/", + assert_string_equal_free("Pidgin (http://pidgin.im/)", yahoo_html_to_codes("Pidgin")); #endif @@ -160,12 +160,24 @@ /* font color */ assert_string_equal_free("\x1B[#E71414mred\x1B[#000000m", yahoo_html_to_codes("red")); + assert_string_equal_free("\x1B[#FF0000mred\x1B[#000000m \x1B[#0000FFmblue\x1B[#000000m black", + yahoo_html_to_codes("red blue black")); /* font size */ assert_string_equal_free("test", yahoo_html_to_codes("test")); assert_string_equal_free("test", yahoo_html_to_codes("test")); + + /* combinations */ + assert_string_equal_free("\x1B[#FF0000mredsmall rednormal\x1B[#000000m", + yahoo_html_to_codes("redsmall rednormal")); + + assert_string_equal_free("\x1B[#FF0000mredsmall \x1B[#00FF00mgreennormal\x1B[#FF0000m rednormal\x1B[#000000m", + yahoo_html_to_codes("redsmall greennormal rednormal")); + + assert_string_equal_free("\x1B[1mbold \x1B[#FF0000mred larger \x1B[#000000mbacktoblack normalsize\x1B[#FF0000m\x1B[#000000m\x1B[x1m", + yahoo_html_to_codes("bold red larger backtoblack normalsize")); } END_TEST