[TASK] Database creating fails due to not allowed characters
authorNicole Cordes <n.cordes@biz-design.biz>
Fri, 21 Sep 2012 09:57:30 +0000 (11:57 +0200)
committerJigal van Hemert <jigal@xs4all.nl>
Fri, 21 Sep 2012 20:11:28 +0000 (22:11 +0200)
Due to compatibility the CREATE DATABASE statement is used without quotes.
At least for MySQL databases there are limited characters allowed to use
in unquoted database names (0-9,a-z,A-Z$_). At the moment the database
name is parsed with enabled hyphen but this is obviously not allowed. The
parsing has to be changed to meet the MySQL limitation as well.

Change-Id: I24dcf99bb9baed6a4794183de0eb4f99a0948b7c
Resolves: #41151
Releases: 4.5, 4.6, 4.7, 6.0
Reviewed-on: http://review.typo3.org/14812
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
typo3/sysext/install/Classes/Installer.php

index c868574..74e736b 100644 (file)
@@ -3111,7 +3111,8 @@ REMOTE_ADDR was \'' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REMOTE
                                // New database?
                                if (trim($this->INSTALL['Database']['NEW_DATABASE_NAME'])) {
                                        $newDatabaseName = trim($this->INSTALL['Database']['NEW_DATABASE_NAME']);
-                                       if (!preg_match('/[^[:alnum:]_-]/', $newDatabaseName)) {
+                                               // Hyphen is not allowed in unquoted database names (at least for MySQL databases)
+                                       if (!preg_match('/[^[:alnum:]_]/', $newDatabaseName)) {
                                                if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) {
                                                        if ($GLOBALS['TYPO3_DB']->admin_query('CREATE DATABASE ' . $newDatabaseName . ' CHARACTER SET utf8')) {
                                                                $this->INSTALL['Database']['typo_db'] = $newDatabaseName;
@@ -3131,7 +3132,7 @@ REMOTE_ADDR was \'' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REMOTE
                                        } else {
                                                $this->errorMessages[] = '
                                                                The NEW database name \'' . $newDatabaseName . '\' was
-                                                               not alphanumeric, a-zA-Z0-9_- (...not created)
+                                                               not alphanumeric, a-zA-Z0-9_ (...not created)
                                                        ';
                                        }
                                }