diff options
Diffstat (limited to 'mysys/charset.c')
-rw-r--r-- | mysys/charset.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/mysys/charset.c b/mysys/charset.c index cb2379f8723..bb8f2d178b9 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -215,7 +215,7 @@ static int add_collation(CHARSET_INFO *cs) if (!strcmp(cs->csname,"ucs2") ) { -#ifdef HAVE_CHARSET_ucs2 +#if defined(HAVE_CHARSET_ucs2) && defined(HAVE_UCA_COLLATIONS) new->cset= my_charset_ucs2_general_uca.cset; new->coll= my_charset_ucs2_general_uca.coll; new->strxfrm_multiply= my_charset_ucs2_general_uca.strxfrm_multiply; @@ -581,6 +581,23 @@ ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to, from--; continue; } + /* + If the next character appears to begin a multi-byte character, we + escape that first byte of that apparent multi-byte character. (The + character just looks like a multi-byte character -- if it were actually + a multi-byte character, it would have been passed through in the test + above.) + + Without this check, we can create a problem by converting an invalid + multi-byte character into a valid one. For example, 0xbf27 is not + a valid GBK character, but 0xbf5c is. (0x27 = ', 0x5c = \) + */ + if (use_mb_flag && (l= my_mbcharlen(charset_info, *from)) > 1) + { + *to++= '\\'; + *to++= *from; + continue; + } #endif switch (*from) { case 0: /* Must be escaped for 'mysql' */ |