diff options
author | jimw@mysql.com <> | 2005-02-17 16:16:58 -0800 |
---|---|---|
committer | jimw@mysql.com <> | 2005-02-17 16:16:58 -0800 |
commit | 7eb8c130f7fc6a5aea90233c31ef219796a17390 (patch) | |
tree | 76f459723b9f122eb50373fe7c42ffc72f277131 /mysys | |
parent | 613e09a92a52d15a9b8838c8ef2e42707018dfeb (diff) | |
parent | 3c700572b45c578c5e408b991ac0bed8b75a6832 (diff) | |
download | mariadb-git-7eb8c130f7fc6a5aea90233c31ef219796a17390.tar.gz |
Merge
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/charset.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mysys/charset.c b/mysys/charset.c index cb2379f8723..5587a6d685f 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -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' */ |