diff libpurple/protocols/sametime/sametime.c @ 18596:8261beed9653

Fixes Ticket #1707 Crash with invalid UTF-8 status message from other Sametime client
author Sean Egan <seanegan@gmail.com>
date Sun, 22 Jul 2007 00:25:56 +0000
parents ab6d2763b8d8
children b8cbc7659a5a 5734f1c98a37
line wrap: on
line diff
--- a/libpurple/protocols/sametime/sametime.c	Sat Jul 21 23:30:59 2007 +0000
+++ b/libpurple/protocols/sametime/sametime.c	Sun Jul 22 00:25:56 2007 +0000
@@ -3189,7 +3189,8 @@
   pd = gc->proto_data;
 
   ret = mwServiceAware_getText(pd->srvc_aware, &t);
-  return ret? g_markup_escape_text(ret, -1): NULL;
+  
+  return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL;
 }
 
 
@@ -3254,7 +3255,7 @@
   message = mwServiceAware_getText(pd->srvc_aware, &idb);
   status = status_text(b);
 
-  if(message != NULL && purple_utf8_strcasecmp(status, message)) {
+  if(message != NULL && g_utf8_validate(message, -1, NULL) && purple_utf8_strcasecmp(status, message)) {
     tmp = g_markup_escape_text(message, -1);
 	purple_notify_user_info_add_pair(user_info, status, tmp);
     g_free(tmp);
@@ -4151,7 +4152,7 @@
 
 	/* XXX Is this adding a status message in its own section rather than with the "Status" label? */
     tmp2 = mwServiceAware_getText(pd->srvc_aware, &idb);
-    if(tmp2) {
+    if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) {
       tmp = g_markup_escape_text(tmp2, -1);
 	  purple_notify_user_info_add_section_break(user_info);
 	  purple_notify_user_info_add_pair(user_info, NULL, tmp);