Mercurial > pidgin
comparison libpurple/protocols/oscar/oscar.c @ 28669:ce29013a5f3a
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.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 29 Nov 2009 01:50:36 +0000 |
parents | ca0f113fee11 |
children | c06e1f777e42 |
comparison
equal
deleted
inserted
replaced
28668:23f6f80f45ed | 28669:ce29013a5f3a |
---|---|
2459 /* | 2459 /* |
2460 * Convert iChat color tags to normal font tags. | 2460 * Convert iChat color tags to normal font tags. |
2461 */ | 2461 */ |
2462 if (purple_markup_find_tag("body", tmp, &start, &end, &attribs)) | 2462 if (purple_markup_find_tag("body", tmp, &start, &end, &attribs)) |
2463 { | 2463 { |
2464 int len; | |
2465 char *tmp2, *body; | |
2464 const char *ichattextcolor, *ichatballooncolor; | 2466 const char *ichattextcolor, *ichatballooncolor; |
2465 const char *start2, *end2; | 2467 const char *slash_body_start, *slash_body_end = NULL; /* </body> */ |
2466 GData *unused; | 2468 GData *unused; |
2467 | 2469 |
2468 /* | 2470 /* |
2469 * Find the ending </body> so we can strip off the outer <html/> | 2471 * Find the ending </body> so we can strip off the outer <html/> |
2470 * and <body/> | 2472 * and <body/> |
2471 */ | 2473 */ |
2472 if (purple_markup_find_tag("/body", end + 1, &start2, &end2, &unused)) | 2474 if (purple_markup_find_tag("/body", end + 1, &slash_body_start, &slash_body_end, &unused)) |
2473 { | 2475 { |
2474 gchar *tmp2; | 2476 body = g_strndup(start, slash_body_end - start + 1); |
2475 tmp2 = g_strndup(end + 1, (start2 - 1) - (end + 1) + 1); | |
2476 g_free(tmp); | |
2477 tmp = tmp2; | |
2478 g_datalist_clear(&unused); | 2477 g_datalist_clear(&unused); |
2478 } | |
2479 else | |
2480 { | |
2481 purple_debug_warning("oscar", "Broken message contains <body> but not </body>!\n"); | |
2482 /* Take everything after <body> */ | |
2483 body = g_strdup(start); | |
2479 } | 2484 } |
2480 | 2485 |
2481 ichattextcolor = g_datalist_get_data(&attribs, "ichattextcolor"); | 2486 ichattextcolor = g_datalist_get_data(&attribs, "ichattextcolor"); |
2482 if (ichattextcolor != NULL) | 2487 if (ichattextcolor != NULL) |
2483 { | 2488 { |
2484 gchar *tmp2; | 2489 tmp2 = g_strdup_printf("<font color=\"%s\">%s</font>", ichattextcolor, body); |
2485 tmp2 = g_strdup_printf("<font color=\"%s\">%s</font>", ichattextcolor, tmp); | 2490 g_free(body); |
2486 g_free(tmp); | 2491 body = tmp2; |
2487 tmp = tmp2; | |
2488 } | 2492 } |
2489 | 2493 |
2490 ichatballooncolor = g_datalist_get_data(&attribs, "ichatballooncolor"); | 2494 ichatballooncolor = g_datalist_get_data(&attribs, "ichatballooncolor"); |
2491 if (ichatballooncolor != NULL) | 2495 if (ichatballooncolor != NULL) |
2492 { | 2496 { |
2493 gchar *tmp2; | 2497 tmp2 = g_strdup_printf("<font back=\"%s\">%s</font>", ichatballooncolor, body); |
2494 tmp2 = g_strdup_printf("<font back=\"%s\">%s</font>", ichatballooncolor, tmp); | 2498 g_free(body); |
2495 g_free(tmp); | 2499 body = tmp2; |
2496 tmp = tmp2; | |
2497 } | 2500 } |
2498 | 2501 |
2499 g_datalist_clear(&attribs); | 2502 g_datalist_clear(&attribs); |
2503 | |
2504 len = start - tmp; | |
2505 tmp2 = g_strdup_printf("%.*s%s%s", len, tmp, body, slash_body_end ? slash_body_end + 1: "</body>"); | |
2506 g_free(tmp); | |
2507 g_free(body); | |
2508 | |
2509 tmp = tmp2; | |
2510 } | |
2511 | |
2512 /* | |
2513 * Are there <html/> surrounding tags? If so, strip them out, too. | |
2514 */ | |
2515 if (purple_markup_find_tag("html", tmp, &start, &end, &attribs)) | |
2516 { | |
2517 gchar *tmp2; | |
2518 int len; | |
2519 | |
2520 g_datalist_clear(&attribs); | |
2521 | |
2522 len = start - tmp; | |
2523 tmp2 = g_strdup_printf("%.*s%s", len, tmp, end + 1); | |
2524 g_free(tmp); | |
2525 tmp = tmp2; | |
2526 } | |
2527 | |
2528 if (purple_markup_find_tag("/html", tmp, &start, &end, &attribs)) | |
2529 { | |
2530 gchar *tmp2; | |
2531 int len; | |
2532 | |
2533 g_datalist_clear(&attribs); | |
2534 | |
2535 len = start - tmp; | |
2536 tmp2 = g_strdup_printf("%.*s%s", len, tmp, end + 1); | |
2537 g_free(tmp); | |
2538 tmp = tmp2; | |
2500 } | 2539 } |
2501 | 2540 |
2502 serv_got_im(gc, userinfo->bn, tmp, flags, | 2541 serv_got_im(gc, userinfo->bn, tmp, flags, |
2503 (args->icbmflags & AIM_IMFLAGS_OFFLINE) ? args->timestamp : time(NULL)); | 2542 (args->icbmflags & AIM_IMFLAGS_OFFLINE) ? args->timestamp : time(NULL)); |
2504 g_free(tmp); | 2543 g_free(tmp); |