Skip to content

Commit 6e1fc37

Browse files
committed
Check url is well-formed before parsing #2558
1 parent 2798970 commit 6e1fc37

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/database/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ impl Database {
7979
{
8080
let opt: ConnectOptions = opt.into();
8181

82+
if url::Url::parse(&opt.url).is_err() {
83+
return Err(conn_err(format!(
84+
"The connection string '{}' cannot be parsed.",
85+
opt.url
86+
)));
87+
}
88+
8289
#[cfg(feature = "sqlx-mysql")]
8390
if DbBackend::MySql.is_prefix_of(&opt.url) {
8491
return crate::SqlxMySqlConnector::connect(opt).await;

0 commit comments

Comments
 (0)