changeset 27998:617e7a90b69c

Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me but it did for the guy reporting the bug. Might be architecture dependent or compile option dependent. In any case this is bad and we should release 2.6.1 tonight or tomorrow
author Mark Doliner <mark@kingant.net>
date Tue, 18 Aug 2009 23:52:14 +0000
parents c69c79921f93
children 901476dc70b9 584e063285b7 a195ce8eb805
files libpurple/protocols/yahoo/util.c libpurple/tests/test_yahoo_util.c
diffstat 2 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/util.c	Tue Aug 18 23:03:47 2009 +0000
+++ b/libpurple/protocols/yahoo/util.c	Tue Aug 18 23:52:14 2009 +0000
@@ -553,12 +553,15 @@
 #endif /* !USE_CSS_FORMATTING */
 
 				} else if ((match = g_hash_table_lookup(esc_codes_ht, code))) {
-					gboolean is_closing_tag;
-					gchar *tag_name;
-
-					tag_name = yahoo_markup_get_tag_name(match, &is_closing_tag);
-					yahoo_codes_to_html_add_tag(&cur, match, is_closing_tag, tag_name, FALSE);
-					g_free(tag_name);
+					/* Some tags are in the hash table only because we
+					 * want to ignore them */
+					if (match[0] != '\0') {
+						gboolean is_closing_tag;
+						gchar *tag_name;
+						tag_name = yahoo_markup_get_tag_name(match, &is_closing_tag);
+						yahoo_codes_to_html_add_tag(&cur, match, is_closing_tag, tag_name, FALSE);
+						g_free(tag_name);
+					}
 
 				} else {
 					purple_debug_error("yahoo",
--- a/libpurple/tests/test_yahoo_util.c	Tue Aug 18 23:03:47 2009 +0000
+++ b/libpurple/tests/test_yahoo_util.c	Tue Aug 18 23:52:14 2009 +0000
@@ -50,6 +50,10 @@
 	assert_string_equal_free("<b>bold <i>bolditalic <u>bolditalicunderline</u></i></b><i><u> italicunderline</u></i>",
 			yahoo_codes_to_html("\x1B[1mbold \x1B[2mbolditalic \x1B[4mbolditalicunderline\x1B[x1m italicunderline"));
 
+	/* link */
+	assert_string_equal_free("http://pidgin.im/",
+			yahoo_codes_to_html("\x1B[lmhttp://pidgin.im/\x1B[xlm"));
+
 #ifdef USE_CSS_FORMATTING
 	/* font color */
 	assert_string_equal_free("<span style='color: #0000FF'>blue</span>",