ntbb-database: Don't leak partial passwords in errors (#1838)

This commit is contained in:
Mia 2021-07-12 15:24:09 -05:00 committed by GitHub
parent fb9ceab6f9
commit 5458936f2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,12 +23,17 @@ class PSDatabase {
function connect() {
if (!$this->db) {
$this->db = new PDO(
"mysql:dbname={$this->database};host={$this->server};charset={$this->charset}",
$this->username,
$this->password
);
$this->db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
try {
$this->db = new PDO(
"mysql:dbname={$this->database};host={$this->server};charset={$this->charset}",
$this->username,
$this->password
);
$this->db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
} catch (Exception $e) {
// hide passwords and stuff from stacktrace
throw new ErrorException($e->getMessage());
}
}
}
function query($query, $params=false) {