comparison src/protocols/yahoo/util.c @ 8440:be172fe866ac

[gaim-migrate @ 9170] " This makes yahoo not send out html entities. This is because the official client will show them raw instead of parsing them. This also makes us show html entities raw, since that's how the other end meant them. This has some side effects if you type in something that's valid yahoo markup. The other end will probably see it as markup and render it as such, etc. Oh well, it's the way yahoo works. Better this than "everyone says i'm typing "!" (This isn't the patch Sean said to write. I still need to write that. This is sort of related though.)" --marv committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sun, 14 Mar 2004 05:37:41 +0000
parents 7e9fdaab7163
children 622fd4e800b4
comparison
equal deleted inserted replaced
8439:b08d8874d933 8440:be172fe866ac
134 g_hash_table_insert(ht, "x1", "</B>"); 134 g_hash_table_insert(ht, "x1", "</B>");
135 g_hash_table_insert(ht, "2", "<I>"); 135 g_hash_table_insert(ht, "2", "<I>");
136 g_hash_table_insert(ht, "x2", "</I>"); 136 g_hash_table_insert(ht, "x2", "</I>");
137 g_hash_table_insert(ht, "4", "<U>"); 137 g_hash_table_insert(ht, "4", "<U>");
138 g_hash_table_insert(ht, "x4", "</U>"); 138 g_hash_table_insert(ht, "x4", "</U>");
139 g_hash_table_insert(ht, "</font>", "</font>");
140 139
141 /* these just tell us the text they surround is supposed 140 /* these just tell us the text they surround is supposed
142 * to be a link. gaim figures that out on its own so we 141 * to be a link. gaim figures that out on its own so we
143 * just ignore it. 142 * just ignore it.
144 */ 143 */
182 g_hash_table_insert(ht, "<u>", "<u>"); 181 g_hash_table_insert(ht, "<u>", "<u>");
183 182
184 g_hash_table_insert(ht, "</b>", "</b>"); 183 g_hash_table_insert(ht, "</b>", "</b>");
185 g_hash_table_insert(ht, "</i>", "</i>"); 184 g_hash_table_insert(ht, "</i>", "</i>");
186 g_hash_table_insert(ht, "</u>", "</u>"); 185 g_hash_table_insert(ht, "</u>", "</u>");
186 g_hash_table_insert(ht, "</font>", "</font>");
187 } 187 }
188 188
189 void yahoo_dest_colorht() 189 void yahoo_dest_colorht()
190 { 190 {
191 g_hash_table_destroy(ht); 191 g_hash_table_destroy(ht);
313 } else { 313 } else {
314 if (x[i] == '<') 314 if (x[i] == '<')
315 g_string_append(s, "&lt;"); 315 g_string_append(s, "&lt;");
316 else if (x[i] == '>') 316 else if (x[i] == '>')
317 g_string_append(s, "&gt;"); 317 g_string_append(s, "&gt;");
318 else if (x[i] == '&')
319 g_string_append(s, "&amp;");
320 else if (x[i] == '"')
321 g_string_append(s, "&quot;");
318 else 322 else
319 g_string_append_c(s, x[i]); 323 g_string_append_c(s, x[i]);
320 } 324 }
321 } 325 }
322 326
535 int i, j, len; 539 int i, j, len;
536 GString *dest; 540 GString *dest;
537 char *ret, *esc; 541 char *ret, *esc;
538 GQueue *colors, *tags; 542 GQueue *colors, *tags;
539 GQueue *ftattr = NULL; 543 GQueue *ftattr = NULL;
544 gboolean no_more_specials = FALSE;
540 545
541 546
542 colors = g_queue_new(); 547 colors = g_queue_new();
543 tags = g_queue_new(); 548 tags = g_queue_new();
544 549
545 dest = g_string_sized_new(strlen(src)); 550 dest = g_string_sized_new(strlen(src));
546 551
547 for (i = 0, len = strlen(src); i < len; i++) { 552 for (i = 0, len = strlen(src); i < len; i++) {
548 553
549 if (src[i] == '<') { 554 if (!no_more_specials && src[i] == '<') {
550 j = i; 555 j = i;
551 556
552 while (1) { 557 while (1) {
553 j++; 558 j++;
554 559
555 if (j >= len) { /* no '>' */ 560 if (j >= len) { /* no '>' */
556 g_string_append_len(dest, &src[i], len - i); 561 g_string_append_c(dest, src[i]);
557 i = len; 562 no_more_specials = TRUE;
558
559 break; 563 break;
560 } 564 }
561 565
562 if (src[j] == '<') { 566 if (src[j] == '<') {
567 /* FIXME: This doesn't convert outgoing entities.
568 * However, I suspect this case may never
569 * happen anymore because of the entities.
570 */
563 g_string_append_len(dest, &src[i], j - i); 571 g_string_append_len(dest, &src[i], j - i);
564 i = j - 1; 572 i = j - 1;
565 if (ftattr) { 573 if (ftattr) {
566 fontattr *f; 574 fontattr *f;
567 575
603 611
604 break; 612 break;
605 } 613 }
606 614
607 if (src[j] == '>') { 615 if (src[j] == '>') {
616 /* This has some problems like the FIXME for the
617 * '<' case. and like that case, I suspect the case
618 * that this has problems is won't happen anymore anyway.
619 */
608 int sublen = j - i - 1; 620 int sublen = j - i - 1;
609 621
610 if (sublen) { 622 if (sublen) {
611 if (!g_ascii_strncasecmp(&src[i+1], "B", sublen)) { 623 if (!g_ascii_strncasecmp(&src[i+1], "B", sublen)) {
612 g_string_append(dest, "\033[1m"); 624 g_string_append(dest, "\033[1m");
647 } 659 }
648 660
649 } 661 }
650 662
651 } else { 663 } else {
652 g_string_append_c(dest, src[i]); 664 if (((len - i) >= 4) && !strncmp(&src[i], "&lt;", 4)) {
665 g_string_append_c(dest, '<');
666 i += 3;
667 } else if (((len - i) >= 4) && !strncmp(&src[i], "&gt;", 4)) {
668 g_string_append_c(dest, '>');
669 i += 3;
670 } else if (((len - i) >= 5) && !strncmp(&src[i], "&amp;", 4)) {
671 g_string_append_c(dest, '&');
672 i += 4;
673 } else if (((len - i) >= 6) && !strncmp(&src[i], "&quot;", 4)) {
674 g_string_append_c(dest, '"');
675 i += 5;
676 } else {
677 g_string_append_c(dest, src[i]);
678 }
653 } 679 }
654 } 680 }
655 681
656 ret = dest->str; 682 ret = dest->str;
657 g_string_free(dest, FALSE); 683 g_string_free(dest, FALSE);