Mercurial > pidgin
comparison libpurple/protocols/irc/parse.c @ 32367:00ea5f8ef509
Fix a leak in IRC when accepting a UTF-8 message with a non-UTF-8 encoding.
Fixes #14700
| author | Ethan Blanton <elb@pidgin.im> |
|---|---|
| date | Tue, 29 Nov 2011 03:58:50 +0000 |
| parents | 062f5781aa57 |
| children | ca4714f51bb1 |
comparison
equal
deleted
inserted
replaced
| 32341:15e80ced77a2 | 32367:00ea5f8ef509 |
|---|---|
| 258 const gchar *charset, *enclist; | 258 const gchar *charset, *enclist; |
| 259 gchar **encodings; | 259 gchar **encodings; |
| 260 gboolean autodetect; | 260 gboolean autodetect; |
| 261 int i; | 261 int i; |
| 262 | 262 |
| 263 autodetect = purple_account_get_bool(irc->account, "autodetect_utf8", IRC_DEFAULT_AUTODETECT); | |
| 264 | |
| 265 if (autodetect && g_utf8_validate(string, -1, NULL)) { | |
| 266 return g_strdup(string); | |
| 267 } | |
| 268 | |
| 263 enclist = purple_account_get_string(irc->account, "encoding", IRC_DEFAULT_CHARSET); | 269 enclist = purple_account_get_string(irc->account, "encoding", IRC_DEFAULT_CHARSET); |
| 264 encodings = g_strsplit(enclist, ",", -1); | 270 encodings = g_strsplit(enclist, ",", -1); |
| 265 | 271 |
| 266 if (encodings[0] == NULL) { | 272 if (encodings[0] == NULL) { |
| 267 g_strfreev(encodings); | 273 g_strfreev(encodings); |
| 268 return purple_utf8_salvage(string); | 274 return purple_utf8_salvage(string); |
| 269 } | |
| 270 | |
| 271 autodetect = purple_account_get_bool(irc->account, "autodetect_utf8", IRC_DEFAULT_AUTODETECT); | |
| 272 | |
| 273 if (autodetect && g_utf8_validate(string, -1, NULL)) { | |
| 274 return g_strdup(string); | |
| 275 } | 275 } |
| 276 | 276 |
| 277 for (i = 0; encodings[i] != NULL; i++) { | 277 for (i = 0; encodings[i] != NULL; i++) { |
| 278 charset = encodings[i]; | 278 charset = encodings[i]; |
| 279 while (*charset == ' ') | 279 while (*charset == ' ') |
