changeset 17635:7fd8bd8594fe

disapproval of revision '71ed79a95ae8fc95aafeebbea64a8adcf4db8bfd'
author Andreas Monitzer <pidgin@monitzer.com>
date Thu, 12 Jul 2007 02:45:23 +0000
parents ba48f21e0795
children 42d9a1b56d08
files libpurple/util.c
diffstat 1 files changed, 41 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/util.c	Wed Jul 11 15:57:14 2007 +0000
+++ b/libpurple/util.c	Thu Jul 12 02:45:23 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;