# HG changeset patch # User Paul Aurich # Date 1259459436 0 # Node ID ce29013a5f3a847f1d250c64b9aa2508a2e62c49 # Parent 23f6f80f45ed1fc653ff8faf087e21f5dc26c389 oscar: Fix the parsing code from ichatballooncolors that broke receiving markup in 2.6.2. This also fixes the horrendous AIM Blast markup syntax. Closes #10234. diff -r 23f6f80f45ed -r ce29013a5f3a ChangeLog --- a/ChangeLog Sat Nov 28 23:13:55 2009 +0000 +++ b/ChangeLog Sun Nov 29 01:50:36 2009 +0000 @@ -20,6 +20,7 @@ * The simultaneous login account option is respected when using the clientLogin authentication method. * Fix offline message retrieval (broken in 2.6.3) + * Fix handling of markup on some messages (broken in 2.6.2) * Fix SSL when clientLogin is enabled. * Fix sending and receiving Unicode characters in a Direct IM diff -r 23f6f80f45ed -r ce29013a5f3a libpurple/protocols/oscar/oscar.c --- a/libpurple/protocols/oscar/oscar.c Sat Nov 28 23:13:55 2009 +0000 +++ b/libpurple/protocols/oscar/oscar.c Sun Nov 29 01:50:36 2009 +0000 @@ -2461,42 +2461,81 @@ */ if (purple_markup_find_tag("body", tmp, &start, &end, &attribs)) { + int len; + char *tmp2, *body; const char *ichattextcolor, *ichatballooncolor; - const char *start2, *end2; + const char *slash_body_start, *slash_body_end = NULL; /* */ GData *unused; /* * Find the ending so we can strip off the outer * and */ - if (purple_markup_find_tag("/body", end + 1, &start2, &end2, &unused)) + if (purple_markup_find_tag("/body", end + 1, &slash_body_start, &slash_body_end, &unused)) { - gchar *tmp2; - tmp2 = g_strndup(end + 1, (start2 - 1) - (end + 1) + 1); - g_free(tmp); - tmp = tmp2; + body = g_strndup(start, slash_body_end - start + 1); g_datalist_clear(&unused); } + else + { + purple_debug_warning("oscar", "Broken message contains but not !\n"); + /* Take everything after */ + body = g_strdup(start); + } ichattextcolor = g_datalist_get_data(&attribs, "ichattextcolor"); if (ichattextcolor != NULL) { - gchar *tmp2; - tmp2 = g_strdup_printf("%s", ichattextcolor, tmp); - g_free(tmp); - tmp = tmp2; + tmp2 = g_strdup_printf("%s", ichattextcolor, body); + g_free(body); + body = tmp2; } ichatballooncolor = g_datalist_get_data(&attribs, "ichatballooncolor"); if (ichatballooncolor != NULL) { - gchar *tmp2; - tmp2 = g_strdup_printf("%s", ichatballooncolor, tmp); - g_free(tmp); - tmp = tmp2; + tmp2 = g_strdup_printf("%s", ichatballooncolor, body); + g_free(body); + body = tmp2; } g_datalist_clear(&attribs); + + len = start - tmp; + tmp2 = g_strdup_printf("%.*s%s%s", len, tmp, body, slash_body_end ? slash_body_end + 1: ""); + g_free(tmp); + g_free(body); + + tmp = tmp2; + } + + /* + * Are there surrounding tags? If so, strip them out, too. + */ + if (purple_markup_find_tag("html", tmp, &start, &end, &attribs)) + { + gchar *tmp2; + int len; + + g_datalist_clear(&attribs); + + len = start - tmp; + tmp2 = g_strdup_printf("%.*s%s", len, tmp, end + 1); + g_free(tmp); + tmp = tmp2; + } + + if (purple_markup_find_tag("/html", tmp, &start, &end, &attribs)) + { + gchar *tmp2; + int len; + + g_datalist_clear(&attribs); + + len = start - tmp; + tmp2 = g_strdup_printf("%.*s%s", len, tmp, end + 1); + g_free(tmp); + tmp = tmp2; } serv_got_im(gc, userinfo->bn, tmp, flags,