Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorNitish Bezzala <nbezzala@yahoo.com>2016-04-26 23:14:24 +0300
committerThomas Steur <tsteur@users.noreply.github.com>2016-04-26 23:14:24 +0300
commit1266ba27a82880f252f2e59994dc9d4bf5705b06 (patch)
treef1f23b0145e0a23948e83ad5813b40e0f2fceb00 /core
parent425fcea8b6e0de720dc85622728775e5c8f955c3 (diff)
allow + in database names during setup (#10091)
Diffstat (limited to 'core')
-rw-r--r--core/DbHelper.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/DbHelper.php b/core/DbHelper.php
index 25b1f56455..96ba2c5a1d 100644
--- a/core/DbHelper.php
+++ b/core/DbHelper.php
@@ -186,4 +186,19 @@ class DbHelper
ArchiveTableCreator::refreshTableList($forceReload = true);
}
+
+ /**
+ * Returns true if the string is a valid database name for MySQL. MySQL allows + in the database names.
+ * Database names that start with a-Z or 0-9 and contain a-Z, 0-9, underscore(_), dash(-), plus(+), and dot(.) will be accepted.
+ * File names beginning with anything but a-Z or 0-9 will be rejected (including .htaccess for example).
+ * File names containing anything other than above mentioned will also be rejected (file names with spaces won't be accepted).
+ *
+ * @param string $dbname
+ * @return bool
+ */
+ public static function isValidDbname($dbname)
+ {
+ return (0 !== preg_match('/(^[a-zA-Z0-9]+([a-zA-Z_0-9.-\+]*))$/D', $dbname));
+ }
+
}