]> source.dussan.org Git - nextcloud-server.git/commitdiff
postgresql - add quotes around user names
authorSimon L <szaimen@e.mail.de>
Tue, 7 Mar 2023 23:37:19 +0000 (00:37 +0100)
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>
Fri, 10 Mar 2023 02:04:01 +0000 (02:04 +0000)
fix https://github.com/nextcloud/server/issues/37114

Signed-off-by: Simon L <szaimen@e.mail.de>
lib/private/Setup/PostgreSQL.php

index af816c7ad0432e70ef97d4a79d6575d534c2e74b..ee1773487290d5da2b1a7533eac75d8667e83b3b 100644 (file)
@@ -120,7 +120,7 @@ class PostgreSQL extends AbstractDatabase {
        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) {
@@ -170,10 +170,10 @@ class PostgreSQL extends AbstractDatabase {
                        }
 
                        // 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) {