Skip to content

Commit

Permalink
MDL-10607 - support single quotes in db user/password in installer
Browse files Browse the repository at this point in the history
merged from MOODLE_19_STABLE
  • Loading branch information
poltawski committed Dec 23, 2007
1 parent 392e736 commit 2961367
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,9 @@
$str .= '$CFG->dbhost = \''.addslashes($INSTALL['dbhost'])."';\r\n";
if (!empty($INSTALL['dbname'])) {
$str .= '$CFG->dbname = \''.$INSTALL['dbname']."';\r\n";
$str .= '$CFG->dbuser = \''.$INSTALL['dbuser']."';\r\n";
$str .= '$CFG->dbpass = \''.$INSTALL['dbpass']."';\r\n";
// support single quotes in db user/passwords
$str .= '$CFG->dbuser = \''.addsingleslashes($INSTALL['dbuser'])."';\r\n";
$str .= '$CFG->dbpass = \''.addsingleslashes($INSTALL['dbpass'])."';\r\n";
}
$str .= '$CFG->dbpersist = false;'."\r\n";
$str .= '$CFG->prefix = \''.$INSTALL['prefix']."';\r\n";
Expand Down Expand Up @@ -1279,4 +1280,12 @@ function toggledbinfo() {

<?php
}

/**
* Add slashes for single quotes so they can be
* included in single quoted string
*/
function addsingleslashes($input){
return str_replace("'", "\'", $input);
}
?>

0 comments on commit 2961367

Please sign in to comment.