Skip to content

Commit

Permalink
MDL-43189 core: Validate db prefix during installation
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies authored and snake committed Nov 1, 2019
1 parent a78ed9e commit 7a902de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lang/en/install.php
Expand Up @@ -144,6 +144,7 @@
$string['inputwebadress'] = 'Web address :';
$string['inputwebdirectory'] = 'Moodle directory:';
$string['installation'] = 'Installation';
$string['invaliddbprefix'] = 'Invalid prefix. The prefix can only consist of lower case letters and underscore.';
$string['langdownloaderror'] = 'Unfortunately the language "{$a}" could not be downloaded. The installation process will continue in English.';
$string['langdownloadok'] = 'The language "{$a}" was installed successfully. The installation process will continue in this language.';
$string['memorylimit'] = 'Memory limit';
Expand Down
3 changes: 3 additions & 0 deletions lib/installlib.php
Expand Up @@ -179,6 +179,9 @@ function install_helpbutton($url, $title='') {
* @return string
*/
function install_db_validate($database, $dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions) {
if (!preg_match('/^[a-z_]*$/', $prefix)) {
return get_string('invaliddbprefix', 'install');
}
try {
try {
$database->connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
Expand Down

0 comments on commit 7a902de

Please sign in to comment.