From 35f3ec1944ff7954c9c2eb7b902ecf028f92fe98 Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Wed, 27 Nov 2024 14:45:46 -0800 Subject: [PATCH] fix(mysql): percent-decode database name (#3612) Duplicates the fix to Postgres in #3593 to the MySQL driver. The SQLite driver already does this: https://github.com/launchbadge/sqlx/blob/e3ef8baf23bc0266959282814c014e482418eef2/sqlx-sqlite/src/options/parse.rs#L29-L32 --- sqlx-mysql/src/options/parse.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sqlx-mysql/src/options/parse.rs b/sqlx-mysql/src/options/parse.rs index 37f71a6e..e31ddc46 100644 --- a/sqlx-mysql/src/options/parse.rs +++ b/sqlx-mysql/src/options/parse.rs @@ -38,7 +38,11 @@ impl MySqlConnectOptions { let path = url.path().trim_start_matches('/'); if !path.is_empty() { - options = options.database(path); + options = options.database( + &percent_decode_str(path) + .decode_utf8() + .map_err(Error::config)?, + ); } for (key, value) in url.query_pairs().into_iter() {