Mercurial > pidgin.yaz
changeset 29020:f4a95b3424d1
Make yahoo_codes_to_html not crash when given an empty string, or a string
containing just unknown markup, and add a couple of tests to the testsuite
for these. Hopefully fixes https://bugzilla.redhat.com/show_bug.cgi?id=541341
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Wed, 25 Nov 2009 16:39:29 +0000 |
parents | b5a4df52fb0f |
children | 7622d3f86752 |
files | libpurple/protocols/yahoo/util.c libpurple/tests/test_yahoo_util.c |
diffstat | 2 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/util.c Wed Nov 25 16:10:28 2009 +0000 +++ b/libpurple/protocols/yahoo/util.c Wed Nov 25 16:39:29 2009 +0000 @@ -656,7 +656,10 @@ /* Strip off the outter HTML node */ /* This probably isn't necessary, especially if we made the outter HTML * node an empty span. But the HTML is simpler this way. */ - xmlstr2 = g_strndup(xmlstr1 + 6, strlen(xmlstr1) - 13); + if (!purple_strequal(xmlstr1, "<html/>")) + xmlstr2 = g_strndup(xmlstr1 + 6, strlen(xmlstr1) - 13); + else + xmlstr2 = g_strdup(""); g_free(xmlstr1); esc = g_strescape(x, NULL);
--- a/libpurple/tests/test_yahoo_util.c Wed Nov 25 16:10:28 2009 +0000 +++ b/libpurple/tests/test_yahoo_util.c Wed Nov 25 16:39:29 2009 +0000 @@ -15,6 +15,10 @@ START_TEST(test_codes_to_html) { + assert_string_equal_free("", + yahoo_codes_to_html("")); + assert_string_equal_free("", + yahoo_codes_to_html("\x1B[12345m")); assert_string_equal_free("plain", yahoo_codes_to_html("plain")); assert_string_equal_free("unknown ansi code",