libpurple/protocols/myspace/markup.c

branch
release-2.2.2
changeset 20198
90ae53934c28
parent 20166
49c243c1fe12
child 20227
37e64bb44c76
equal deleted inserted replaced
20197:7fa31956a26b 20198:90ae53934c28
442 *end = g_strdup("</f>"); 442 *end = g_strdup("</f>");
443 } else if (!purple_utf8_strcasecmp(root->name, "u")) { 443 } else if (!purple_utf8_strcasecmp(root->name, "u")) {
444 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_UNDERLINE); 444 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_UNDERLINE);
445 *end = g_strdup("</f>"); 445 *end = g_strdup("</f>");
446 } else if (!purple_utf8_strcasecmp(root->name, "a")) { 446 } else if (!purple_utf8_strcasecmp(root->name, "a")) {
447 const gchar *href, *link_text; 447 const gchar *href;
448 gchar *link_text;
448 449
449 href = xmlnode_get_attrib(root, "href"); 450 href = xmlnode_get_attrib(root, "href");
450 451
451 if (!href) { 452 if (!href) {
452 href = xmlnode_get_attrib(root, "HREF"); 453 href = xmlnode_get_attrib(root, "HREF");
474 *begin = g_strdup("<a />"); 475 *begin = g_strdup("<a />");
475 } 476 }
476 477
477 /* Sorry, kid. MySpace doesn't support you within <a> tags. */ 478 /* Sorry, kid. MySpace doesn't support you within <a> tags. */
478 xmlnode_free(root->child); 479 xmlnode_free(root->child);
480 g_free(link_text);
479 root->child = NULL; 481 root->child = NULL;
480 482
481 *end = g_strdup(""); 483 *end = g_strdup("");
482 } else if (!purple_utf8_strcasecmp(root->name, "font")) { 484 } else if (!purple_utf8_strcasecmp(root->name, "font")) {
483 const gchar *size; 485 const gchar *size;
565 (node && node->name) ? node->name : "(NULL)"); 567 (node && node->name) ? node->name : "(NULL)");
566 break; 568 break;
567 569
568 case XMLNODE_TYPE_DATA: 570 case XMLNODE_TYPE_DATA:
569 /* Literal text. */ 571 /* Literal text. */
570 inner = g_new0(char, node->data_sz + 1); 572 inner = g_strndup(node->data, node->data_sz);
571 strncpy(inner, node->data, node->data_sz);
572 inner[node->data_sz] = 0;
573
574 purple_debug_info("msim", " ** node data=%s\n", 573 purple_debug_info("msim", " ** node data=%s\n",
575 inner ? inner : "(NULL)"); 574 inner ? inner : "(NULL)");
576 break; 575 break;
577 576
578 default: 577 default:
581 inner = g_strdup(""); 580 inner = g_strdup("");
582 } 581 }
583 582
584 if (inner) { 583 if (inner) {
585 g_string_append(final, inner); 584 g_string_append(final, inner);
585 g_free(inner);
586 inner = NULL;
586 } 587 }
587 } 588 }
588 589
589 /* TODO: Note that msim counts each piece of text enclosed by <f> as 590 /* TODO: Note that msim counts each piece of text enclosed by <f> as
590 * a paragraph and will display each on its own line. You actually have 591 * a paragraph and will display each on its own line. You actually have
591 * to _nest_ <f> tags to intersperse different text in one paragraph! 592 * to _nest_ <f> tags to intersperse different text in one paragraph!
592 * Comment out this line below to see. */ 593 * Comment out this line below to see. */
593 g_string_append(final, end); 594 g_string_append(final, end);
595
596 g_free(begin);
597 g_free(end);
594 598
595 purple_debug_info("msim", "msim_markup_xmlnode_to_gtkhtml: RETURNING %s\n", 599 purple_debug_info("msim", "msim_markup_xmlnode_to_gtkhtml: RETURNING %s\n",
596 (final && final->str) ? final->str : "(NULL)"); 600 (final && final->str) ? final->str : "(NULL)");
597 601
598 return g_string_free(final, FALSE); 602 return g_string_free(final, FALSE);

mercurial