Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of mysql passwords with weird characters in it #2660

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
eldering committed Nov 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 712afd223a5fe01b1afdaae108c78d8aba19a4a1
6 changes: 5 additions & 1 deletion webapp/config/load_db_secrets.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types=1);

Check warning on line 1 in webapp/config/load_db_secrets.php

GitHub Actions / phpcs

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 11 and the first side effect is on line 9.

// This file fetches credentials on the fly from files in etc.
// These settings can later be overridden by Symfony files
@@ -36,7 +36,11 @@
break;
}

return sprintf('mysql://%s:%s@%s:%d/%s?serverVersion=5.7.0', $user, $pass, $host, $port ?? 3306, $db);
return sprintf(
'mysql://%s:%s@%s:%d/%s?serverVersion=5.7.0',
rawurlencode($user), rawurlencode($pass), rawurlencode($host),
$port ?? 3306, rawurlencode($db)
);
}

function get_app_secret(): string
2 changes: 1 addition & 1 deletion webapp/config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ doctrine:
charset: utf8mb4
collate: utf8mb4_unicode_ci

url: '%env(resolve:DATABASE_URL)%'
url: '%env(DATABASE_URL)%'
profiling_collect_backtrace: '%kernel.debug%'
types:
tinyint: App\Doctrine\DBAL\Types\TinyIntType