From e0e374872312a3ab0ba355c33c348243c0f3f116 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Mon, 13 Mar 2023 11:19:29 +0000 Subject: [PATCH] Fix ENGINE escaping Signed-off-by: Kamil Tekiela --- libraries/classes/CreateAddField.php | 8 ++++++-- psalm-baseline.xml | 3 ++- test/classes/CreateAddFieldTest.php | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/libraries/classes/CreateAddField.php b/libraries/classes/CreateAddField.php index 63e320c211..3c29fa4ded 100644 --- a/libraries/classes/CreateAddField.php +++ b/libraries/classes/CreateAddField.php @@ -397,8 +397,12 @@ class CreateAddField . Util::backquote(trim($table)) . ' (' . $sqlStatement . ')'; // Adds table type, character set, comments and partition definition - if (! empty($_POST['tbl_storage_engine']) && ($_POST['tbl_storage_engine'] !== 'Default')) { - $sqlQuery .= ' ENGINE = ' . $this->dbi->escapeString($_POST['tbl_storage_engine']); + if ( + ! empty($_POST['tbl_storage_engine']) + && ($_POST['tbl_storage_engine'] !== 'Default') + && StorageEngine::isValid($_POST['tbl_storage_engine']) + ) { + $sqlQuery .= ' ENGINE = ' . $_POST['tbl_storage_engine']; } if (! empty($_POST['tbl_collation'])) { diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 67cb0580ac..f0a558c0ae 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -4652,13 +4652,14 @@ $_POST['partitions'] - + $_POST['partition_by'] $_POST['partition_count'] $_POST['partition_expr'] $_POST['subpartition_by'] $_POST['subpartition_count'] $_POST['subpartition_expr'] + $_POST['tbl_storage_engine'] diff --git a/test/classes/CreateAddFieldTest.php b/test/classes/CreateAddFieldTest.php index 59f62d6348..470e8c3125 100644 --- a/test/classes/CreateAddFieldTest.php +++ b/test/classes/CreateAddFieldTest.php @@ -263,7 +263,24 @@ class CreateAddFieldTest extends AbstractTestCase ], ], [ - 'CREATE TABLE `db`.`table` () ENGINE = Inno\\\'DB CHARSET=armscii8 COMMENT = \'my \\\'table\';', + 'CREATE TABLE `db`.`table` () ENGINE = dummy CHARSET=armscii8 COMMENT = \'my \\\'table\';', + 'db', + 'table', + [ + 'field_name' => [], + 'primary_indexes' => '{}', + 'indexes' => '{}', + 'unique_indexes' => '{}', + 'fulltext_indexes' => '{}', + 'spatial_indexes' => '{}', + 'tbl_storage_engine' => 'dummy', + 'tbl_collation' => 'armscii8', + 'connection' => 'aaaa', + 'comment' => 'my \'table', + ], + ], + [ + 'CREATE TABLE `db`.`table` () CHARSET=armscii8 COMMENT = \'my \\\'table\';', 'db', 'table', [