Salvage incoming SILC text if necessary. release-2.x.y
authorEthan Blanton <elb@pidgin.im>
Fri, 30 Sep 2011 01:31:04 +0000
branchrelease-2.x.y
changeset69372ee4f474 pushlog
parent 364a3c96654a
child 323975c94f79
child 42d2acf32425
Salvage incoming SILC text if necessary.

Fixes #14636
libpurple/protocols/silc/ops.c
     1.1 --- a/libpurple/protocols/silc/ops.c
     1.2 +++ b/libpurple/protocols/silc/ops.c
     1.3 @@ -408,9 +408,16 @@
     1.4  	}
     1.5  
     1.6  	if (flags & SILC_MESSAGE_FLAG_UTF8) {
     1.7 -		tmp = g_markup_escape_text((const char *)message, -1);
     1.8 +		const char *msg = (const char *)message;
     1.9 +		char *salvaged = NULL;
    1.10 +		if (!g_utf8_validate((const char *)message, -1, NULL)) {
    1.11 +			salvaged = purple_utf8_salvage((const char *)message);
    1.12 +			msg = salvaged;
    1.13 +		}
    1.14 +		tmp = g_markup_escape_text(msg, -1);
    1.15  		/* Send to Purple */
    1.16  		serv_got_im(gc, sender->nickname, tmp, 0, time(NULL));
    1.17 +		g_free(salvaged);
    1.18  		g_free(tmp);
    1.19  	}
    1.20  }