diff options
author | jimw@mysql.com <> | 2005-02-09 16:14:13 -0800 |
---|---|---|
committer | jimw@mysql.com <> | 2005-02-09 16:14:13 -0800 |
commit | 5bb39302abab8ecd4214b214d9de46c551053a3d (patch) | |
tree | fc0e31ce18ee1b43ae86ca71d4120e68d998d2e2 /mysys | |
parent | dcc65b77a676bfa545135295fdda20ec2af4de0d (diff) | |
download | mariadb-git-5bb39302abab8ecd4214b214d9de46c551053a3d.tar.gz |
When escaping a string in a multi-byte character set, escape all bytes of
a character that appears to be a multi-byte character based on its first
byte, but is not actually a valid multi-byte character. (Bug #8378)
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/charset.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/mysys/charset.c b/mysys/charset.c index cb2379f8723..934125ead4a 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -581,6 +581,26 @@ 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 all of the bytes of that apparent 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) + { + while (l--) + { + *to++= '\\'; + *to++= *from++; + } + from--; + continue; + } #endif switch (*from) { case 0: /* Must be escaped for 'mysql' */ |