Harden installer against bad characters in the database name or prefix. Fixes #1866.

This commit is contained in:
Bharat Mediratta
2012-05-15 10:54:18 -07:00
parent 05b50f2edf
commit 3caf3cc323
4 changed files with 11 additions and 4 deletions

View File

@@ -65,14 +65,14 @@ abstract class Database extends Database_Core {
$open_brace = strpos($sql, "TO {") + 4;
$close_brace = strpos($sql, "}", $open_brace);
$name = substr($sql, $open_brace, $close_brace - $open_brace);
$this->_table_names["{{$name}}"] = "{$prefix}$name";
$this->_table_names["{{$name}}"] = "`{$prefix}$name`";
}
if (!isset($this->_table_names)) {
// This should only run once on the first query
$this->_table_names = array();
foreach($this->list_tables() as $table_name) {
$this->_table_names["{{$table_name}}"] = $prefix . $table_name;
$this->_table_names["{{$table_name}}"] = "`{$prefix}{$table_name}`";
}
}