diff --git a/replibyte/src/config.rs b/replibyte/src/config.rs index 547f12cc..b6d5e2e6 100644 --- a/replibyte/src/config.rs +++ b/replibyte/src/config.rs @@ -424,7 +424,9 @@ fn get_username(url: &Url) -> Result { fn get_password(url: &Url) -> Result { match url.password() { - Some(password) => Ok(password.to_string()), + Some(password) => Ok(percent_decode_str(&password) + .decode_utf8_lossy() + .to_string()), None => Ok(String::new()), // no password } } @@ -619,6 +621,20 @@ mod tests { ) } + #[test] + fn parse_postgres_connection_uri_with_password_with_special_chars_db() { + assert_eq!( + parse_connection_uri("postgres://root:%aqdz^e@localhost:5432/db").unwrap(), + ConnectionUri::Postgres( + "localhost".to_string(), + 5432, + "root".to_string(), + "%aqdz^e".to_string(), + "db".to_string(), + ), + ) + } + #[test] fn parse_mongodb_connection_uri() { assert!(parse_connection_uri("mongodb://root:password").is_err());