changeset 32256:d9d33a4b5632

Salvage incoming SILC text if necessary. Fixes #14636
author Ethan Blanton <elb@pidgin.im>
date Fri, 30 Sep 2011 01:31:04 +0000
parents 88a46649de3d
children 81d3c4d2eb73 062f5781aa57
files libpurple/protocols/silc/ops.c
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/silc/ops.c	Sun Sep 11 04:18:46 2011 +0000
+++ b/libpurple/protocols/silc/ops.c	Fri Sep 30 01:31:04 2011 +0000
@@ -408,9 +408,16 @@
 	}
 
 	if (flags & SILC_MESSAGE_FLAG_UTF8) {
-		tmp = g_markup_escape_text((const char *)message, -1);
+		const char *msg = (const char *)message;
+		char *salvaged = NULL;
+		if (!g_utf8_validate((const char *)message, -1, NULL)) {
+			salvaged = purple_utf8_salvage((const char *)message);
+			msg = salvaged;
+		}
+		tmp = g_markup_escape_text(msg, -1);
 		/* Send to Purple */
 		serv_got_im(gc, sender->nickname, tmp, 0, time(NULL));
+		g_free(salvaged);
 		g_free(tmp);
 	}
 }