summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2016-12-08 13:45:17 +0100
committerGitHub <noreply@github.com>2016-12-08 13:45:17 +0100
commit880121d31007a0679c1a30a2b9cf86c2ade4789a (patch)
tree0933d8db808b1b5df0b681bc1a76532fffae13bc
parentce707912b47dcd78cdf451cc6af3aa7d75db3d1c (diff)
parent9ebd5d5bb20af9178e071c3c6f3b41d9a9bc8be0 (diff)
downloadnextcloud-server-880121d31007a0679c1a30a2b9cf86c2ade4789a.tar.gz
nextcloud-server-880121d31007a0679c1a30a2b9cf86c2ade4789a.zip
Merge pull request #2556 from Lartza/fix-setup-pgsql-quotes
Quote database and role in queries
-rw-r--r--lib/private/Setup/PostgreSQL.php8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/private/Setup/PostgreSQL.php b/lib/private/Setup/PostgreSQL.php
index 14325a18efe..4f4f8a03231 100644
--- a/lib/private/Setup/PostgreSQL.php
+++ b/lib/private/Setup/PostgreSQL.php
@@ -111,7 +111,7 @@ class PostgreSQL extends AbstractDatabase {
private function createDatabase(IDBConnection $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) {
@@ -119,7 +119,7 @@ class PostgreSQL extends AbstractDatabase {
$this->logger->logException($e);
}
} else {
- $query = $connection->prepare("REVOKE ALL PRIVILEGES ON DATABASE " . addslashes($this->dbName) . " FROM PUBLIC");
+ $query = $connection->prepare("REVOKE ALL PRIVILEGES ON DATABASE \"" . addslashes($this->dbName) . "\" FROM PUBLIC");
try {
$query->execute();
} catch (DatabaseException $e) {
@@ -153,10 +153,10 @@ class PostgreSQL extends AbstractDatabase {
try {
if ($this->userExists($connection)) {
// change the password
- $query = $connection->prepare("ALTER ROLE " . addslashes($this->dbUser) . " WITH CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
+ $query = $connection->prepare("ALTER ROLE \"" . addslashes($this->dbUser) . "\" WITH CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
} else {
// 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();
} catch (DatabaseException $e) {