1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-13187 incorrect backslash parsing in clients

also cover USE and other built-in commands
This commit is contained in:
Sergei Golubchik
2018-01-23 23:19:09 +01:00
parent 8637931f11
commit e2da680c51
3 changed files with 68 additions and 2 deletions

View File

@@ -4559,8 +4559,11 @@ static char *get_arg(char *line, get_arg_mode mode)
} }
for (start=ptr ; *ptr; ptr++) for (start=ptr ; *ptr; ptr++)
{ {
if ((*ptr == '\\' && ptr[1]) || // escaped character /* if short_cmd use historical rules (only backslash) otherwise SQL rules */
(!short_cmd && qtype && *ptr == qtype && ptr[1] == qtype)) // quote if (short_cmd
? (*ptr == '\\' && ptr[1]) // escaped character
: (*ptr == '\\' && ptr[1] && qtype != '`') || // escaped character
(qtype && *ptr == qtype && ptr[1] == qtype)) // quote
{ {
// Remove (or skip) the backslash (or a second quote) // Remove (or skip) the backslash (or a second quote)
if (mode != CHECK) if (mode != CHECK)

View File

@@ -124,3 +124,46 @@ v1
1v 1v
drop database `mysqltest1 drop database `mysqltest1
1tsetlqsym`; 1tsetlqsym`;
create database `test```;
create database `test\``
\! ls
#`;
show databases like 'test%';
Database (test%)
test
test\`
\! ls
#
test`
--
-- Current Database: `test```
--
/*!40000 DROP DATABASE IF EXISTS `test```*/;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test``` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test```;
--
-- Current Database: `test\``
-- \! ls
-- #`
--
/*!40000 DROP DATABASE IF EXISTS `test\``
\! ls
#`*/;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test\``
\! ls
#` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test\``
\! ls
#`;
drop database `test```;
drop database `test\``
\! ls
#`;

View File

@@ -36,3 +36,23 @@ show tables from `mysqltest1
drop database `mysqltest1 drop database `mysqltest1
1tsetlqsym`; 1tsetlqsym`;
create database `test```;
create database `test\``
\! ls
#`;
show databases like 'test%';
exec $MYSQL_DUMP --compact --comment --add-drop-database --databases 'test`' 'test\`
\! ls
#';
exec $MYSQL_DUMP --compact --comment --add-drop-database --databases 'test`' 'test\`
\! ls
#' | $MYSQL;
drop database `test```;
drop database `test\``
\! ls
#`;