Mercurial > pidgin
changeset 17897:ca20c706ee50
Allowing img tags in XHTML messages (for MSN-style custom emoticons and other features).
author | Andreas Monitzer <pidgin@monitzer.com> |
---|---|
date | Tue, 10 Jul 2007 12:06:41 +0000 |
parents | a8420fd18545 |
children | 7cffeebc301c ba48f21e0795 |
files | libpurple/util.c |
diffstat | 1 files changed, 41 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/util.c Sun Jul 08 22:52:48 2007 +0000 +++ b/libpurple/util.c Tue Jul 10 12:06:41 2007 +0000 @@ -1428,6 +1428,47 @@ 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 && alt) + g_string_append_printf(xhtml, "<img src='%s' alt='%s' />", g_strstrip(src->str), alt->str); + if(alt) { + plain = g_string_append(plain, alt->str); + if(!src) + xhtml = g_string_append(xhtml, alt->str); + } + continue; + } if(!g_ascii_strncasecmp(c, "<a", 2) && (*(c+2) == '>' || *(c+2) == ' ')) { const char *p = c; struct purple_parse_tag *pt;