Merge branch 'sprint/feedback#2869' into 'master'
* Fix sql injection. See merge request easycorp/zentaopms!7504
This commit is contained in:
@@ -274,6 +274,7 @@ class convert extends control
|
||||
if($method == 'db')
|
||||
{
|
||||
$dbName = $this->post->dbName;
|
||||
if(!$this->convert->checkDBName($dbName)) die('Invalid database name.');
|
||||
if(!$dbName)
|
||||
{
|
||||
$response['result'] = 'fail';
|
||||
@@ -456,7 +457,7 @@ class convert extends control
|
||||
if(isset($result['finished']) and $result['finished'])
|
||||
{
|
||||
return print $this->send(array('result' => 'finished', 'message' => $this->lang->convert->jira->importSuccessfully));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$type = zget($this->lang->convert->jira->objectList, $result['type'], $result['type']);
|
||||
|
||||
@@ -45,6 +45,7 @@ class convertModel extends model
|
||||
*/
|
||||
public function dbExists($dbName = '')
|
||||
{
|
||||
if(!$this->checkDBName($dbName)) die('Invalid database name.');
|
||||
$statement = $this->dbh->prepare('SHOW DATABASES like ?');
|
||||
$statement->execute(array($dbName));
|
||||
return $statement->fetch();
|
||||
@@ -1520,4 +1521,17 @@ EOT;
|
||||
if(file_exists($filePath)) @unlink($filePath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check dbName is valide.
|
||||
*
|
||||
* @param int $string
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function checkDBName($dbName)
|
||||
{
|
||||
if(preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $dbName)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user