Skip to content

Commit b68c4d5

Browse files
committed
Quote user, password, and dbname in connection string
1 parent fd7c266 commit b68c4d5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/PostgresConfig.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,17 @@ public function getConnectionString(): string
153153

154154
$user = $this->getUser();
155155
if ($user !== null) {
156-
$chunks[] = "user=" . $user;
156+
$chunks[] = \sprintf("user='%s'", \addslashes($user));
157157
}
158158

159159
$password = $this->getPassword();
160160
if ($password !== null) {
161-
$chunks[] = "password=" . $password;
161+
$chunks[] = \sprintf("password='%s'", \addslashes($password));
162162
}
163163

164164
$database = $this->getDatabase();
165165
if ($database !== null) {
166-
$chunks[] = "dbname=" . $database;
166+
$chunks[] = \sprintf("dbname='%s'", \addslashes($database));
167167
}
168168

169169
if ($this->sslMode !== null) {

0 commit comments

Comments
 (0)