changeset 19262:450090c68351

When converting to xhtml, only add URLs in angle brackets if it doesn't match the cdata. Fixes #2445
author Sean Egan <seanegan@gmail.com>
date Sat, 11 Aug 2007 19:40:59 +0000
parents 88c6bf371abb
children 428562735971
files libpurple/Makefile.am libpurple/util.c
diffstat 2 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/Makefile.am	Sat Aug 11 17:57:43 2007 +0000
+++ b/libpurple/Makefile.am	Sat Aug 11 19:40:59 2007 +0000
@@ -22,9 +22,6 @@
 		win32/giowin32.c \
 		win32/win32dep.h
 
-if USE_GCONFTOOL
-GCONF_DIR=gconf
-endif
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = purple.pc
--- a/libpurple/util.c	Sat Aug 11 17:57:43 2007 +0000
+++ b/libpurple/util.c	Sat Aug 11 19:40:59 2007 +0000
@@ -1338,6 +1338,7 @@
 	GString *xhtml = NULL;
 	GString *plain = NULL;
 	GString *url = NULL;
+	GString *cdata = NULL;
 	GList *tags = NULL, *tag;
 	const char *c = html;
 
@@ -1367,7 +1368,13 @@
 							g_string_append_printf(xhtml, "</%s>", pt->dest_tag);
 						if(plain && !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 (cdata && url && !g_string_equal(cdata, url))
+								g_string_append_printf(plain, " <%s>", g_strstrip(url->str));
+							if (cdata) {
+								g_string_free(cdata, TRUE);
+								cdata = NULL;
+							}
+							
 						}
 						if(tags == tag)
 							break;
@@ -1537,6 +1544,7 @@
 							const char *q = p + strlen("href=");
 							g_string_free(url, TRUE);
 							url = g_string_new("");
+							cdata = g_string_new("");
 							if(*q == '\'' || *q == '\"')
 								q++;
 							while(*q && *q != '\"' && *q != '\'' && *q != ' ') {
@@ -1725,6 +1733,8 @@
 				xhtml = g_string_append_c(xhtml, *c);
 			if(plain)
 				plain = g_string_append_c(plain, *c);
+			if(cdata)
+				cdata = g_string_append_c(cdata, *c);
 			c++;
 		}
 	}