Skip to content

Commit 05e7160

Browse files
committed
URL encode variables that go into a MySQL credentials URI
See for reference: - https://dev.mysql.com/doc/refman/8.0/en/connecting-using-uri-or-key-value-pairs.html#connecting-using-uri - https://symfony.com/doc/current/doctrine.html but note that we must use `rawurlencode` instead of `urlencode` which differ in how they encode a space (as tested). Fixes: #2651 Closes: #2502 as this is likely fixed but I couldn't reproduce it
1 parent 9f12b77 commit 05e7160

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Diff for: webapp/config/load_db_secrets.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ function get_db_url(): string
3636
break;
3737
}
3838

39-
return sprintf('mysql://%s:%s@%s:%d/%s?serverVersion=5.7.0', $user, $pass, $host, $port ?? 3306, $db);
39+
return sprintf(
40+
'mysql://%s:%s@%s:%d/%s?serverVersion=5.7.0',
41+
rawurlencode($user), rawurlencode($pass), rawurlencode($host),
42+
$port ?? 3306, rawurlencode($db)
43+
);
4044
}
4145

4246
function get_app_secret(): string

Diff for: webapp/config/packages/doctrine.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ doctrine:
77
charset: utf8mb4
88
collate: utf8mb4_unicode_ci
99

10-
url: '%env(resolve:DATABASE_URL)%'
10+
url: '%env(DATABASE_URL)%'
1111
profiling_collect_backtrace: '%kernel.debug%'
1212
types:
1313
tinyint: App\Doctrine\DBAL\Types\TinyIntType

0 commit comments

Comments
 (0)