Mercurial > pidgin
changeset 18687:42939d215988
merge of '34c6d2f9e1c14630370e582d136064c340ef8e88'
and '4539cc7ee5b462dcae69d1993ee6f10c2c819964'
author | Andreas Monitzer <pidgin@monitzer.com> |
---|---|
date | Thu, 12 Jul 2007 02:51:30 +0000 |
parents | b70664a62de8 (current diff) ddaedccb25b0 (diff) |
children | 42d9a1b56d08 |
files | libpurple/protocols/bonjour/dns_sd.c libpurple/protocols/bonjour/dns_sd.h libpurple/protocols/qq/group_misc.c libpurple/protocols/qq/group_misc.h libpurple/util.c |
diffstat | 1 files changed, 46 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/util.c Thu Jul 12 02:20:55 2007 +0000 +++ b/libpurple/util.c Thu Jul 12 02:51:30 2007 +0000 @@ -1416,6 +1416,7 @@ ALLOW_TAG("q"); ALLOW_TAG("span"); ALLOW_TAG("strong"); + ALLOW_TAG("ul"); /* we skip <HR> because it's not legal in XHTML-IM. However, @@ -1434,40 +1435,6 @@ plain = g_string_append_c(plain, '\n'); continue; } - if(!g_ascii_strncasecmp(c, "<img", 4) && (*(c+4) == '>' || *(c+4) == ' ')) { - const char *p = c; - GString *src = NULL; - struct purple_parse_tag *pt; - while(*p && *p != '>') { - if(!g_ascii_strncasecmp(p, "src=", strlen("src="))) { - const char *q = p + strlen("src="); - src = g_string_new(""); - if(*q == '\'' || *q == '\"') - q++; - while(*q && *q != '\"' && *q != '\'' && *q != ' ') { - src = g_string_append_c(src, *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 = "img"; - pt->dest_tag = "img"; - tags = g_list_prepend(tags, pt); - if(xhtml && src && src->len) - g_string_append_printf(xhtml, "<img src='%s' alt=''>", g_strstrip(src->str)); - else - pt->ignore = TRUE; - if (src) - g_string_free(src, TRUE); - continue; - } if(!g_ascii_strncasecmp(c, "<b>", 3) || !g_ascii_strncasecmp(c, "<bold>", strlen("<bold>"))) { struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); pt->src_tag = *(c+2) == '>' ? "b" : "bold"; @@ -1518,6 +1485,50 @@ xhtml = g_string_append(xhtml, "<span style='vertical-align:super;'>"); continue; } + if(!g_ascii_strncasecmp(c, "<img", 4) && (*(c+4) == '>' || *(c+4) == ' ')) { + const char *p = c; + GString *src = NULL, *alt = NULL; + while(*p && *p != '>') { + if(!g_ascii_strncasecmp(p, "src=", strlen("src="))) { + const char *q = p + strlen("src="); + src = g_string_new(""); + if(*q == '\'' || *q == '\"') + q++; + while(*q && *q != '\"' && *q != '\'' && *q != ' ') { + src = g_string_append_c(src, *q); + q++; + } + p = q; + } else if(!g_ascii_strncasecmp(p, "alt=", strlen("alt="))) { + const char *q = p + strlen("alt="); + alt = g_string_new(""); + if(*q == '\'' || *q == '\"') + q++; + while(*q && *q != '\"' && *q != '\'' && *q != ' ') { + alt = g_string_append_c(alt, *q); + q++; + } + p = q; + } + p++; + } + if ((c = strchr(c, '>')) != NULL) + c++; + else + c = p; + /* src and alt are required! */ + if(src && xhtml) + g_string_append_printf(xhtml, "<img src='%s' alt='%s' />", g_strstrip(src->str), alt?alt->str:""); + if(alt) { + if(plain) + plain = g_string_append(plain, alt->str); + if(!src && xhtml) + xhtml = g_string_append(xhtml, alt->str); + } + g_string_free(alt, TRUE); + g_string_free(src, TRUE); + continue; + } if(!g_ascii_strncasecmp(c, "<a", 2) && (*(c+2) == '>' || *(c+2) == ' ')) { const char *p = c; struct purple_parse_tag *pt; @@ -1721,7 +1732,7 @@ struct purple_parse_tag *pt = tag->data; if(!pt->ignore) g_string_append_printf(xhtml, "</%s>", pt->dest_tag); - } + g_list_free(tags); } *xhtml_out = g_strdup(xhtml->str); if(xhtml_out)