changeset 15787:a1564afbad84

Patch from plivesey, submitted in Adium Trac #5753 (http://trac.adiumx.com/ticket/5753), which fixes a memory stomper which occurred if the msn prpl were passed HTML with multiple style tags of the same type. This doesn't happen in pidgin, because the gtkhtml widget knows that msn can only have one all-or-none instance of each style, but libpurple should be able to handle being passed any sort of HTML. This therefore fixes an Adium crash.
author Evan Schoenberg <evan.s@dreskin.net>
date Mon, 12 Mar 2007 22:58:03 +0000
parents f75aa2bf4973
children 8cf610a18481
files libpurple/protocols/msn/msn-utils.c
diffstat 1 files changed, 25 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/msn-utils.c	Sat Mar 10 17:24:53 2007 +0000
+++ b/libpurple/protocols/msn/msn-utils.c	Mon Mar 12 22:58:03 2007 +0000
@@ -174,6 +174,11 @@
 	char fonteffect[4];
 	char fontcolor[7];
 
+	gboolean haveBold = FALSE;
+	gboolean haveItalic = FALSE;
+	gboolean haveUnderline = FALSE;
+	gboolean haveStrikethrough = FALSE;
+
 	g_return_if_fail(html       != NULL);
 	g_return_if_fail(attributes != NULL);
 	g_return_if_fail(message    != NULL);
@@ -197,22 +202,38 @@
 			}
 			else if (!g_ascii_strncasecmp(c + 1, "i>", 2))
 			{
-				strcat(fonteffect, "I");
+				if ( haveItalic == FALSE )
+				{
+					strcat(fonteffect, "I");
+					haveItalic = TRUE;
+				}
 				c += 3;
 			}
 			else if (!g_ascii_strncasecmp(c + 1, "b>", 2))
 			{
-				strcat(fonteffect, "B");
+				if ( haveBold == FALSE )
+				{
+					strcat(fonteffect, "B");
+					haveBold = TRUE;
+				}
 				c += 3;
 			}
 			else if (!g_ascii_strncasecmp(c + 1, "u>", 2))
 			{
-				strcat(fonteffect, "U");
+				if ( haveUnderline == FALSE )
+				{
+					strcat(fonteffect, "U");
+					haveUnderline = TRUE;
+				}
 				c += 3;
 			}
 			else if (!g_ascii_strncasecmp(c + 1, "s>", 2))
 			{
-				strcat(fonteffect, "S");
+				if ( haveStrikethrough == FALSE )
+				{
+					strcat(fonteffect, "S");
+					haveStrikethrough = TRUE;
+				}
 				c += 3;
 			}
 			else if (!g_ascii_strncasecmp(c + 1, "a href=\"", 8))