pidgin: dca32611: oscar: Fix the parsing code from ichatba...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Sat Nov 28 20:57:07 EST 2009
-----------------------------------------------------------------
Revision: dca326117c63899086cbb34178d48ec19c767111
Ancestor: 5471a4305312ead74567c9099c837adcbebb640c
Author: darkrain42 at pidgin.im
Date: 2009-11-29T01:50:36
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/dca326117c63899086cbb34178d48ec19c767111
Modified files:
ChangeLog libpurple/protocols/oscar/oscar.c
ChangeLog:
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.
-------------- next part --------------
============================================================
--- ChangeLog df5e36c21ff0f2d7dfa41793abe40df89d1a6601
+++ ChangeLog 7e0ac393d8f4ac5d0bcf45d6480a39bc6db148ea
@@ -20,6 +20,7 @@ version 2.6.4 (??/??/20??):
* 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
============================================================
--- libpurple/protocols/oscar/oscar.c 47bf0894561dc277e644876b82685ac8e663b9a0
+++ libpurple/protocols/oscar/oscar.c 841d5ffd79863ad73b63ef2bff4a816d977e0b71
@@ -2461,44 +2461,83 @@ static int incomingim_chan1(OscarData *o
*/
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; /* </body> */
GData *unused;
/*
* Find the ending </body> so we can strip off the outer <html/>
* and <body/>
*/
- 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 <body> but not </body>!\n");
+ /* Take everything after <body> */
+ body = g_strdup(start);
+ }
ichattextcolor = g_datalist_get_data(&attribs, "ichattextcolor");
if (ichattextcolor != NULL)
{
- gchar *tmp2;
- tmp2 = g_strdup_printf("<font color=\"%s\">%s</font>", ichattextcolor, tmp);
- g_free(tmp);
- tmp = tmp2;
+ tmp2 = g_strdup_printf("<font color=\"%s\">%s</font>", ichattextcolor, body);
+ g_free(body);
+ body = tmp2;
}
ichatballooncolor = g_datalist_get_data(&attribs, "ichatballooncolor");
if (ichatballooncolor != NULL)
{
- gchar *tmp2;
- tmp2 = g_strdup_printf("<font back=\"%s\">%s</font>", ichatballooncolor, tmp);
- g_free(tmp);
- tmp = tmp2;
+ tmp2 = g_strdup_printf("<font back=\"%s\">%s</font>", 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: "</body>");
+ g_free(tmp);
+ g_free(body);
+
+ tmp = tmp2;
}
+ /*
+ * Are there <html/> 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,
(args->icbmflags & AIM_IMFLAGS_OFFLINE) ? args->timestamp : time(NULL));
g_free(tmp);
More information about the Commits
mailing list