diff src/protocols/msn/utils.c @ 6358:8ba58b296cc1

[gaim-migrate @ 6862] This should fix a problem I encountered when I realized again that Qt sucks and likes to crash when I have certain tags not closed. The format string conversion code in MSN was taken from the old MSN prpl, and that code didn't close tags. This should fix that problem. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 03 Aug 2003 02:16:15 +0000
parents 13a37cacd10b
children dfde69e105ae
line wrap: on
line diff
--- a/src/protocols/msn/utils.c	Sat Aug 02 15:27:00 2003 +0000
+++ b/src/protocols/msn/utils.c	Sun Aug 03 02:16:15 2003 +0000
@@ -80,33 +80,38 @@
 	return buf;
 }
 
-char *
-msn_parse_format(const char *mime)
+void
+msn_parse_format(const char *mime, char **pre_ret, char **post_ret)
 {
 	char *cur;
-	GString *ret = g_string_new(NULL);
+	GString *pre  = g_string_new(NULL);
+	GString *post = g_string_new(NULL);
 	unsigned int colors[3];
 
+	if (pre_ret  != NULL) *pre_ret  = NULL;
+	if (post_ret != NULL) *post_ret = NULL;
+
 	cur = strstr(mime, "FN=");
 
 	if (cur && (*(cur = cur + 3) != ';')) {
-		ret = g_string_append(ret, "<FONT FACE=\"");
+		pre = g_string_append(pre, "<FONT FACE=\"");
 
 		while (*cur && *cur != ';') {
-			ret = g_string_append_c(ret, *cur);
+			pre = g_string_append_c(pre, *cur);
 			cur++;
 		}
 
-		ret = g_string_append(ret, "\">");
+		pre = g_string_append(pre, "\">");
+		post = g_string_prepend(post, "</FONT>");
 	}
-	
+
 	cur = strstr(mime, "EF=");
 
 	if (cur && (*(cur = cur + 3) != ';')) {
 		while (*cur && *cur != ';') {
-			ret = g_string_append_c(ret, '<');
-			ret = g_string_append_c(ret, *cur);
-			ret = g_string_append_c(ret, '>');
+			pre = g_string_append_c(pre, '<');
+			pre = g_string_append_c(pre, *cur);
+			pre = g_string_append_c(pre, '>');
 			cur++;
 		}
 	}
@@ -136,12 +141,20 @@
 					   "<FONT COLOR=\"#%02hhx%02hhx%02hhx\">",
 					   colors[2], colors[1], colors[0]);
 
-			ret = g_string_append(ret, tag);
+			pre = g_string_append(pre, tag);
+			post = g_string_prepend(post, "</FONT>");
 		}
 	}
 
-	cur = msn_url_decode(ret->str);
-	g_string_free(ret, TRUE);
+	cur = msn_url_decode(pre->str);
+	g_string_free(pre, TRUE);
+
+	if (pre_ret != NULL)
+		*pre_ret = cur;
 
-	return cur;
+	cur = msn_url_decode(post->str);
+	g_string_free(post, TRUE);
+
+	if (post_ret != NULL)
+		*post_ret = cur;
 }