# HG changeset patch # User Christian Hammond # Date 1059876975 0 # Node ID 8ba58b296cc1410598669cf5c1c8352d018b4d7d # Parent 1fa4410d2e13ff7a430fb9b838c626d6be0bf58b [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 diff -r 1fa4410d2e13 -r 8ba58b296cc1 src/protocols/msn/switchboard.c --- a/src/protocols/msn/switchboard.c Sat Aug 02 15:27:00 2003 +0000 +++ b/src/protocols/msn/switchboard.c Sun Aug 03 02:16:15 2003 +0000 @@ -293,7 +293,6 @@ MsnSwitchBoard *swboard = servconn->data; char *body; const char *value; - char *format; int flags = 0; body = g_strdup(msn_message_get_body(msg)); @@ -309,9 +308,14 @@ } if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL) { - format = msn_parse_format(value); + char *pre_format, *post_format; + + msn_parse_format(value, &pre_format, &post_format); - body = g_strdup_printf("%s%s", format, body); + body = g_strdup_printf("%s%s%s", pre_format, body, post_format); + + g_free(pre_format); + g_free(post_format); } if (swboard->chat != NULL) diff -r 1fa4410d2e13 -r 8ba58b296cc1 src/protocols/msn/utils.c --- 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, ""); + pre = g_string_append(pre, "\">"); + post = g_string_prepend(post, ""); } - + 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 @@ "", colors[2], colors[1], colors[0]); - ret = g_string_append(ret, tag); + pre = g_string_append(pre, tag); + post = g_string_prepend(post, ""); } } - 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; } diff -r 1fa4410d2e13 -r 8ba58b296cc1 src/protocols/msn/utils.h --- a/src/protocols/msn/utils.h Sat Aug 02 15:27:00 2003 +0000 +++ b/src/protocols/msn/utils.h Sun Aug 03 02:16:15 2003 +0000 @@ -47,10 +47,12 @@ /** * Parses the MSN message formatting into a format compatible with Gaim. * - * @param mime The mime header with the formatting. + * @param mime The mime header with the formatting. + * @param pre_ret The returned prefix string. + * @param post_ret The returned postfix string. * * @return The new message. */ -char *msn_parse_format(const char *mime); +void msn_parse_format(const char *mime, char **pre_ret, char **post_ret); #endif /* _MSN_UTILS_H_ */