comparison libpurple/util.c @ 25541:411b5a604a17

propagate from branch 'im.pidgin.pidgin' (head cb5420b4b28888af9a419d6ca29f524e552c9cf0) to branch 'im.pidgin.pidgin.yaz' (head 2fb9c50de147c3e10a2bb579beca0cf90ab363d0)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 14 Aug 2007 07:13:22 +0000
parents 4bd16a73769c 450090c68351
children 5e76304ebcc8
comparison
equal deleted inserted replaced
25540:d892a9275d0d 25541:411b5a604a17
1338 char **plain_out) 1338 char **plain_out)
1339 { 1339 {
1340 GString *xhtml = NULL; 1340 GString *xhtml = NULL;
1341 GString *plain = NULL; 1341 GString *plain = NULL;
1342 GString *url = NULL; 1342 GString *url = NULL;
1343 GString *cdata = NULL;
1343 GList *tags = NULL, *tag; 1344 GList *tags = NULL, *tag;
1344 const char *c = html; 1345 const char *c = html;
1345 1346
1346 g_return_if_fail(xhtml_out != NULL || plain_out != NULL); 1347 g_return_if_fail(xhtml_out != NULL || plain_out != NULL);
1347 1348
1367 struct purple_parse_tag *pt = tags->data; 1368 struct purple_parse_tag *pt = tags->data;
1368 if(xhtml) 1369 if(xhtml)
1369 g_string_append_printf(xhtml, "</%s>", pt->dest_tag); 1370 g_string_append_printf(xhtml, "</%s>", pt->dest_tag);
1370 if(plain && !strcmp(pt->src_tag, "a")) { 1371 if(plain && !strcmp(pt->src_tag, "a")) {
1371 /* if this is a link, we have to add the url to the plaintext, too */ 1372 /* if this is a link, we have to add the url to the plaintext, too */
1372 g_string_append_printf(plain, " <%s>", g_strstrip(url->str)); 1373 if (cdata && url && !g_string_equal(cdata, url))
1374 g_string_append_printf(plain, " <%s>", g_strstrip(url->str));
1375 if (cdata) {
1376 g_string_free(cdata, TRUE);
1377 cdata = NULL;
1378 }
1379
1373 } 1380 }
1374 if(tags == tag) 1381 if(tags == tag)
1375 break; 1382 break;
1376 tags = g_list_remove(tags, pt); 1383 tags = g_list_remove(tags, pt);
1377 g_free(pt); 1384 g_free(pt);
1537 while(*p && *p != '>') { 1544 while(*p && *p != '>') {
1538 if(!g_ascii_strncasecmp(p, "href=", strlen("href="))) { 1545 if(!g_ascii_strncasecmp(p, "href=", strlen("href="))) {
1539 const char *q = p + strlen("href="); 1546 const char *q = p + strlen("href=");
1540 g_string_free(url, TRUE); 1547 g_string_free(url, TRUE);
1541 url = g_string_new(""); 1548 url = g_string_new("");
1549 cdata = g_string_new("");
1542 if(*q == '\'' || *q == '\"') 1550 if(*q == '\'' || *q == '\"')
1543 q++; 1551 q++;
1544 while(*q && *q != '\"' && *q != '\'' && *q != ' ') { 1552 while(*q && *q != '\"' && *q != '\'' && *q != ' ') {
1545 url = g_string_append_c(url, *q); 1553 url = g_string_append_c(url, *q);
1546 q++; 1554 q++;
1725 } else { 1733 } else {
1726 if(xhtml) 1734 if(xhtml)
1727 xhtml = g_string_append_c(xhtml, *c); 1735 xhtml = g_string_append_c(xhtml, *c);
1728 if(plain) 1736 if(plain)
1729 plain = g_string_append_c(plain, *c); 1737 plain = g_string_append_c(plain, *c);
1738 if(cdata)
1739 cdata = g_string_append_c(cdata, *c);
1730 c++; 1740 c++;
1731 } 1741 }
1732 } 1742 }
1733 if(xhtml) { 1743 if(xhtml) {
1734 for (tag = tags; tag ; tag = tag->next) { 1744 for (tag = tags; tag ; tag = tag->next) {