Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
7bf50246
Commit
7bf50246
authored
Feb 17, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge
tests/mysql_client_test.c: SCCS merged
parents
cb8b1cf3
9dad64a1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
mysys/charset.c
mysys/charset.c
+17
-0
tests/mysql_client_test.c
tests/mysql_client_test.c
+49
-0
No files found.
mysys/charset.c
View file @
7bf50246
...
...
@@ -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' */
...
...
tests/mysql_client_test.c
View file @
7bf50246
...
...
@@ -11605,6 +11605,54 @@ static void test_bug7990()
}
/*
Test mysql_real_escape_string() with gbk charset
The important part is that 0x27 (') is the second-byte in a invalid
two-byte GBK character here. But 0xbf5c is a valid GBK character, so
it needs to be escaped as 0x5cbf27
*/
#define TEST_BUG8378_IN "\xef\xbb\xbf\x27\xbf\x10"
#define TEST_BUG8378_OUT "\xef\xbb\x5c\xbf\x5c\x27\x5c\xbf\x10"
static
void
test_bug8378
()
{
MYSQL
*
lmysql
;
char
out
[
9
];
/* strlen(TEST_BUG8378)*2+1 */
int
len
;
myheader
(
"test_bug8378"
);
if
(
!
opt_silent
)
fprintf
(
stdout
,
"
\n
Establishing a test connection ..."
);
if
(
!
(
lmysql
=
mysql_init
(
NULL
)))
{
myerror
(
"mysql_init() failed"
);
exit
(
1
);
}
if
(
mysql_options
(
lmysql
,
MYSQL_SET_CHARSET_NAME
,
"gbk"
))
{
myerror
(
"mysql_options() failed"
);
exit
(
1
);
}
if
(
!
(
mysql_real_connect
(
lmysql
,
opt_host
,
opt_user
,
opt_password
,
current_db
,
opt_port
,
opt_unix_socket
,
0
)))
{
myerror
(
"connection failed"
);
exit
(
1
);
}
if
(
!
opt_silent
)
fprintf
(
stdout
,
" OK"
);
len
=
mysql_real_escape_string
(
lmysql
,
out
,
TEST_BUG8378_IN
,
4
);
/* No escaping should have actually happened. */
DIE_UNLESS
(
memcmp
(
out
,
TEST_BUG8378_OUT
,
len
)
==
0
);
mysql_close
(
lmysql
);
}
/*
Read and parse arguments and MySQL options from my.cnf
*/
...
...
@@ -11814,6 +11862,7 @@ static struct my_tests_st my_tests[]= {
{
"test_bug6761"
,
test_bug6761
},
{
"test_bug8330"
,
test_bug8330
},
{
"test_bug7990"
,
test_bug7990
},
{
"test_bug8378"
,
test_bug8378
},
{
0
,
0
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment