changeset 27777:2cb44870580d

- revert msn_message_get_bin_data() and restore true sanitize code for incoming messages. - fix a typo in util.c.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 01 Mar 2008 14:39:04 +0000
parents 492a3798f87c
children 37b4d9d4ab2e
files libpurple/protocols/msn/msg.c libpurple/protocols/msn/switchboard.c libpurple/protocols/msnp9/msg.c libpurple/protocols/msnp9/switchboard.c libpurple/util.c
diffstat 5 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/msg.c	Fri Feb 29 19:18:27 2008 +0000
+++ b/libpurple/protocols/msn/msg.c	Sat Mar 01 14:39:04 2008 +0000
@@ -534,12 +534,12 @@
 const void *
 msn_message_get_bin_data(const MsnMessage *msg, size_t *len)
 {
-	gchar *ret = NULL;
-
 	g_return_val_if_fail(msg != NULL, NULL);
 
-	ret = sanitize_utf((gchar *)msg->body, msg->body_len, len);
-	return ret;
+	if (len)
+		*len = msg->body_len;
+
+	return msg->body;
 }
 
 void
--- a/libpurple/protocols/msn/switchboard.c	Fri Feb 29 19:18:27 2008 +0000
+++ b/libpurple/protocols/msn/switchboard.c	Sat Mar 01 14:39:04 2008 +0000
@@ -842,7 +842,7 @@
 	char *body_str;
 	char *body_enc;
 	char *body_final;
-	size_t body_len;
+	size_t body_len, new_len;
 	const char *passport;
 	const char *value;
 
@@ -850,7 +850,7 @@
 	swboard = cmdproc->data;
 
 	body = msn_message_get_bin_data(msg, &body_len);
-	body_str = g_strndup(body, body_len);
+	body_str = sanitize_utf(body, body_len, &new_len);
 	body_enc = g_markup_escape_text(body_str, -1);
 	g_free(body_str);
 
--- a/libpurple/protocols/msnp9/msg.c	Fri Feb 29 19:18:27 2008 +0000
+++ b/libpurple/protocols/msnp9/msg.c	Sat Mar 01 14:39:04 2008 +0000
@@ -537,12 +537,12 @@
 const void *
 msn_message_get_bin_data(const MsnMessage *msg, size_t *len)
 {
-	gchar *ret = NULL;
-
 	g_return_val_if_fail(msg != NULL, NULL);
 
-	ret = sanitize_utf((gchar *)msg->body, msg->body_len, len);
-	return ret;
+	if (len)
+		*len = msg->body_len;
+
+	return msg->body;
 }
 
 void
--- a/libpurple/protocols/msnp9/switchboard.c	Fri Feb 29 19:18:27 2008 +0000
+++ b/libpurple/protocols/msnp9/switchboard.c	Sat Mar 01 14:39:04 2008 +0000
@@ -834,7 +834,7 @@
 	char *body_str;
 	char *body_enc;
 	char *body_final;
-	size_t body_len;
+	size_t body_len, new_len;
 	const char *passport;
 	const char *value;
 
@@ -842,7 +842,7 @@
 	swboard = cmdproc->data;
 
 	body = msn_message_get_bin_data(msg, &body_len);
-	body_str = g_strndup(body, body_len);
+	body_str = sanitize_utf(body, body_len, &new_len);
 	body_enc = g_markup_escape_text(body_str, -1);
 	g_free(body_str);
 
--- a/libpurple/util.c	Fri Feb 29 19:18:27 2008 +0000
+++ b/libpurple/util.c	Sat Mar 01 14:39:04 2008 +0000
@@ -4814,7 +4814,7 @@
 #ifdef _WIN32
 gchar *sanitize_utf(const gchar *msg, gsize len, gsize *newlen)
 {
-	g_retrun_val_if_fail(msg != NULL, NULL);
+	g_return_val_if_fail(msg != NULL, NULL);
 	g_return_val_if_fail(len > 0, NULL);
 
 	*newlen = len;