mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
Don't assume that 7bit ascii strings are encoded in UTF-8, only validate the strings when they contain octest with highest bit set. (patch by Mikko Rauhala)
fixes http://bugs.irssi.org/index.php?do=details&id=392 git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4300 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
7602b7eff5
commit
da965109ed
@ -80,6 +80,7 @@ char *recode_in(const SERVER_REC *server, const char *str, const char *target)
|
|||||||
char *tagtarget = NULL;
|
char *tagtarget = NULL;
|
||||||
gboolean term_is_utf8, str_is_utf8, translit, recode, autodetect;
|
gboolean term_is_utf8, str_is_utf8, translit, recode, autodetect;
|
||||||
int len;
|
int len;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -90,7 +91,14 @@ char *recode_in(const SERVER_REC *server, const char *str, const char *target)
|
|||||||
|
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
|
||||||
str_is_utf8 = g_utf8_validate(str, len, NULL);
|
/* Only validate for UTF-8 if an 8-bit encoding. */
|
||||||
|
str_is_utf8 = 0;
|
||||||
|
for (i = 0; i < len; ++i) {
|
||||||
|
if (str[i] & 0x80) {
|
||||||
|
str_is_utf8 = g_utf8_validate(str, len, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
translit = settings_get_bool("recode_transliterate");
|
translit = settings_get_bool("recode_transliterate");
|
||||||
autodetect = settings_get_bool("recode_autodetect_utf8");
|
autodetect = settings_get_bool("recode_autodetect_utf8");
|
||||||
term_is_utf8 = recode_get_charset(&to);
|
term_is_utf8 = recode_get_charset(&to);
|
||||||
|
Loading…
Reference in New Issue
Block a user