Mercurial > pidgin
changeset 32258:062f5781aa57
UTF-8 salvage unknown strings in IRC
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Fri, 30 Sep 2011 18:23:57 +0000 |
parents | d9d33a4b5632 |
children | 2dd117990702 |
files | libpurple/protocols/irc/parse.c |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/irc/parse.c Fri Sep 30 01:31:04 2011 +0000 +++ b/libpurple/protocols/irc/parse.c Fri Sep 30 18:23:57 2011 +0000 @@ -708,7 +708,14 @@ switch (fmt[i]) { case 'v': if (!(end = strchr(cur, ' '))) end = cur + strlen(cur); - args[i] = g_strndup(cur, end - cur); + /* This is a string of unknown encoding which we do not + * want to transcode, but it may or may not be valid + * UTF-8, so we'll salvage it. If a nick/channel/target + * field has inadvertently been marked verbatim, this + * could cause weirdness. */ + tmp = g_strndup(cur, end - cur); + args[i] = purple_utf8_salvage(tmp); + g_free(tmp); cur += end - cur; break; case 't': @@ -726,7 +733,9 @@ cur = cur + strlen(cur); break; case '*': - args[i] = g_strdup(cur); + /* Ditto 'v' above; we're going to salvage this in case + * it leaks past the IRC prpl */ + args[i] = purple_utf8_salvage(cur); cur = cur + strlen(cur); break; default: