# HG changeset patch # User Andreas Monitzer # Date 1183927433 0 # Node ID 1b74553c5c08562d3b56e4ef7bc5ee954212f699 # Parent bbd92ee894f2018d20740ad2c2a24630e0207da5 When converting HTML to XHTML and plain text on message send, links in the HTML are converted to 'text' <'url'> in plain text instead of just 'text'. diff -r bbd92ee894f2 -r 1b74553c5c08 libpurple/util.c --- a/libpurple/util.c Tue Jul 03 23:51:26 2007 +0000 +++ b/libpurple/util.c Sun Jul 08 20:43:53 2007 +0000 @@ -1296,6 +1296,7 @@ { GString *xhtml = g_string_new(""); GString *plain = g_string_new(""); + GString *url = NULL; GList *tags = NULL, *tag; const char *c = html; @@ -1315,6 +1316,10 @@ while(tags) { struct purple_parse_tag *pt = tags->data; g_string_append_printf(xhtml, "", pt->dest_tag); + if(!strcmp(pt->src_tag, "a")) { + /* if this is a link, we have to add the url to the plaintext, too */ + g_string_append_printf(plain, " <%s>", g_strstrip(url->str)); + } if(tags == tag) break; tags = g_list_remove(tags, pt); @@ -1338,7 +1343,7 @@ } } } else { /* opening tag */ - ALLOW_TAG("a"); + /*ALLOW_TAG("a");*/ ALLOW_TAG("blockquote"); ALLOW_TAG("cite"); ALLOW_TAG("div"); @@ -1423,6 +1428,35 @@ xhtml = g_string_append(xhtml, ""); continue; } + if(!g_ascii_strncasecmp(c, "' || *(c+2) == ' ')) { + const char *p = c; + struct purple_parse_tag *pt; + while(*p && *p != '>') { + if(!g_ascii_strncasecmp(p, "href=", strlen("href="))) { + const char *q = p + strlen("href="); + g_string_free(url, TRUE); + url = g_string_new(""); + if(*q == '\'' || *q == '\"') + q++; + while(*q && *q != '\"' && *q != '\'' && *q != ' ') { + url = g_string_append_c(url, *q); + q++; + } + p = q; + } + p++; + } + if ((c = strchr(c, '>')) != NULL) + c++; + else + c = p; + pt = g_new0(struct purple_parse_tag, 1); + pt->src_tag = "a"; + pt->dest_tag = "a"; + tags = g_list_prepend(tags, pt); + g_string_append_printf(xhtml, "", g_strstrip(url->str)); + continue; + } if(!g_ascii_strncasecmp(c, "' || *(c+5) == ' ')) { const char *p = c; GString *style = g_string_new(""); @@ -1598,6 +1632,7 @@ *plain_out = g_strdup(plain->str); g_string_free(xhtml, TRUE); g_string_free(plain, TRUE); + g_string_free(url, TRUE); } /* The following are probably reasonable changes: