summaryrefslogtreecommitdiff
path: root/mysys/charset.c
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2005-02-15 11:31:01 -0800
committerunknown <jimw@mysql.com>2005-02-15 11:31:01 -0800
commit9dad64a129a18e8b9d64edcd5947e9eba88f3c41 (patch)
tree2942069b3c0860fe3aab590bc51515d0f43ab93e /mysys/charset.c
parentae14393e7487f3c8a97f3dc44cab7a2c19cdd0a9 (diff)
downloadmariadb-git-9dad64a129a18e8b9d64edcd5947e9eba88f3c41.tar.gz
Only escape the first character in a sequence of bytes that appears to be
a multibyte character, but was not a valid multibyte character. Refinement of fix for Bug #8378. tests/mysql_client_test.c: Fix test (and fix number) for Bug #8378 mysys/charset.c: Fix to only escape the first character in a sequence that appears to be a multibyte character, but was not a valid one.
Diffstat (limited to 'mysys/charset.c')
-rw-r--r--mysys/charset.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/mysys/charset.c b/mysys/charset.c
index 934125ead4a..5587a6d685f 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -583,9 +583,10 @@ ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to,
}
/*
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.)
+ 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
@@ -593,12 +594,8 @@ ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to,
*/
if (use_mb_flag && (l= my_mbcharlen(charset_info, *from)) > 1)
{
- while (l--)
- {
- *to++= '\\';
- *to++= *from++;
- }
- from--;
+ *to++= '\\';
+ *to++= *from;
continue;
}
#endif