From eb9e6358f572a1af157b972d169e4b14f43bf41c Mon Sep 17 00:00:00 2001 From: Benoit Ranque Date: Tue, 5 Nov 2024 19:44:30 -0400 Subject: [PATCH] URL decode database name when parsing connection url --- sqlx-postgres/src/options/parse.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sqlx-postgres/src/options/parse.rs b/sqlx-postgres/src/options/parse.rs index 104001007e..efbf85d8f6 100644 --- a/sqlx-postgres/src/options/parse.rs +++ b/sqlx-postgres/src/options/parse.rs @@ -40,7 +40,11 @@ impl PgConnectOptions { 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() {