pidgin: dcb994e7: Make yahoo_codes_to_html not crash when ...

nosnilmot at pidgin.im nosnilmot at pidgin.im
Wed Nov 25 11:46:40 EST 2009


-----------------------------------------------------------------
Revision: dcb994e72c6cc6245bdcf08a4405b480464d6b35
Ancestor: 35f7590fe0c8ea925cb4e6b18845230f7cfa2a85
Author: nosnilmot at pidgin.im
Date: 2009-11-25T16:39:29
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/dcb994e72c6cc6245bdcf08a4405b480464d6b35

Modified files:
        libpurple/protocols/yahoo/util.c
        libpurple/tests/test_yahoo_util.c

ChangeLog: 

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

-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/util.c	cba4e955575af4f8c2348a54ba9d7d417c6a4a78
+++ libpurple/protocols/yahoo/util.c	cc9f3b7845dd6121684a31b431359c558e94ce5b
@@ -656,7 +656,10 @@ char *yahoo_codes_to_html(const char *x)
 	/* 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);
============================================================
--- libpurple/tests/test_yahoo_util.c	9c3b13ee9ae0356264c378663f1474df48ad777c
+++ libpurple/tests/test_yahoo_util.c	a24180673117e10691df27818ef322b139ceede1
@@ -15,6 +15,10 @@ START_TEST(test_codes_to_html)
 
 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",


More information about the Commits mailing list