changeset 2912:152d726312b2

[gaim-migrate @ 2925] eh committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 21 Dec 2001 23:46:41 +0000
parents 4790fb1272a1
children c914dc05d3fe
files src/conversation.c src/protocols/irc/irc.c src/protocols/yahoo/yahoo.c
diffstat 3 files changed, 47 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/conversation.c	Fri Dec 21 23:27:48 2001 +0000
+++ b/src/conversation.c	Fri Dec 21 23:46:41 2001 +0000
@@ -1151,6 +1151,43 @@
 	g_free(s);
 }
 
+static char *escape_html(char *w, int *l)
+{
+	int c = 0;
+	char *r;
+	int i, x = 0;
+	if (*l == -1) {
+		*l = strlen(w);
+		x = 1;
+	}
+	r = g_malloc(*l * 5 + 1);
+
+	for (i = 0; i < *l; i++) {
+		if (w[i] == '<') {
+			r[c++] = '&';
+			r[c++] = 'l';
+			r[c++] = 't';
+			r[c++] = ';';
+		} else if (w[i] == '&') {
+			r[c++] = '&';
+			r[c++] = 'a';
+			r[c++] = 'm';
+			r[c++] = 'p';
+			r[c++] = ';';
+		} else {
+			r[c++] = w[i];
+		}
+	}
+	r[c] = 0;
+
+	r = g_realloc(r, c + 1);
+	if (x)
+		*l = -1;
+	else
+		*l = c;
+	return r;
+}
+
 static char *html_logize(char *p)
 {
 
@@ -1555,6 +1592,10 @@
 		g_snprintf(buf, BUF_LONG, "<B><FONT COLOR=\"#777777\">%s</FONT></B><BR>", what);
 		gtk_imhtml_append_text(GTK_IMHTML(c->text), buf, -1, 0);
 	} else {
+		if (c->gc->flags & OPT_CONN_HTML)
+			what = g_memdup(what, length);
+		else
+			what = escape_html(what, &length);
 		if (flags & WFLAG_WHISPER) {
 			/* if we're whispering, it's not an autoresponse */
 			if (meify(what, length)) {
@@ -1661,6 +1702,8 @@
 			g_free(t2);
 			g_free(nm);
 		}
+
+		g_free(what);
 	}
 
 	if ((c->is_chat && (chat_options & OPT_CHAT_POPUP)) ||
--- a/src/protocols/irc/irc.c	Fri Dec 21 23:27:48 2001 +0000
+++ b/src/protocols/irc/irc.c	Fri Dec 21 23:46:41 2001 +0000
@@ -1073,6 +1073,8 @@
 	struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1);
 
 	g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", gc->username);
+	gc->flags = OPT_CONN_HTML; /* this is bad. the reason for this is gtkimhtml doesn't
+				      understand the xchat escapes. so we translate. */
 
 	g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username);
 	set_login_progress(gc, 2, buf);
--- a/src/protocols/yahoo/yahoo.c	Fri Dec 21 23:27:48 2001 +0000
+++ b/src/protocols/yahoo/yahoo.c	Fri Dec 21 23:46:41 2001 +0000
@@ -707,6 +707,8 @@
 	struct gaim_connection *gc = new_gaim_conn(user);
 	struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1);
 
+	gc->flags = OPT_CONN_HTML; /* it does to an extent.... */
+
 	set_login_progress(gc, 1, "Connecting");
 
 	yd->fd = -1;