Skip to content

Commit

Permalink
postgresql - add quotes around user names
Browse files Browse the repository at this point in the history
fix #37114

Signed-off-by: Simon L <[email protected]>
  • Loading branch information
szaimen authored and backportbot-nextcloud[bot] committed Mar 10, 2023
1 parent 3cfa52c commit 7fd2458
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/private/Setup/PostgreSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function setupDatabase($username) {
private function createDatabase(Connection $connection) {
if (!$this->databaseExists($connection)) {
//The database does not exists... let's create it
$query = $connection->prepare("CREATE DATABASE " . addslashes($this->dbName) . " OWNER " . addslashes($this->dbUser));
$query = $connection->prepare("CREATE DATABASE " . addslashes($this->dbName) . " OWNER \"" . addslashes($this->dbUser) . '"');
try {
$query->execute();
} catch (DatabaseException $e) {
Expand Down Expand Up @@ -170,10 +170,10 @@ private function createDBUser(Connection $connection) {
}

// create the user
$query = $connection->prepare("CREATE USER " . addslashes($this->dbUser) . " CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
$query = $connection->prepare("CREATE USER \"" . addslashes($this->dbUser) . "\" CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
$query->execute();
if ($this->databaseExists($connection)) {
$query = $connection->prepare('GRANT CONNECT ON DATABASE ' . addslashes($this->dbName) . ' TO '.addslashes($this->dbUser));
$query = $connection->prepare('GRANT CONNECT ON DATABASE ' . addslashes($this->dbName) . ' TO "' . addslashes($this->dbUser) . '"');
$query->execute();
}
} catch (DatabaseException $e) {
Expand Down

0 comments on commit 7fd2458

Please sign in to comment.