mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
Encode connection URL to database
- If you have a database password that contains characters like `#` or `*`, sqlx will error about a InvalidPort, this is due to not encoding the url. [See issue on sqlx](https://github.com/launchbadge/sqlx/issues/1624). - Removed useless statements.
This commit is contained in:
@@ -13,6 +13,7 @@ async-trait = "0.1.51"
|
|||||||
db-core = {path = "../db-core"}
|
db-core = {path = "../db-core"}
|
||||||
futures = "0.3.15"
|
futures = "0.3.15"
|
||||||
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "mysql", "time", "offline" ] }
|
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "mysql", "time", "offline" ] }
|
||||||
|
urlencoding = "2.1.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "2"
|
actix-rt = "2"
|
||||||
|
|||||||
@@ -68,14 +68,13 @@ impl Connect for ConnectionOptions {
|
|||||||
async fn connect(self) -> DBResult<Self::Pool> {
|
async fn connect(self) -> DBResult<Self::Pool> {
|
||||||
let pool = match self {
|
let pool = match self {
|
||||||
Self::Fresh(fresh) => {
|
Self::Fresh(fresh) => {
|
||||||
let mut connect_options =
|
let mut connect_options = sqlx::mysql::MySqlConnectOptions::from_str(
|
||||||
sqlx::mysql::MySqlConnectOptions::from_str(&fresh.url).unwrap();
|
&urlencoding::encode(&fresh.url),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
if fresh.disable_logging {
|
if fresh.disable_logging {
|
||||||
connect_options.disable_statement_logging();
|
connect_options.disable_statement_logging();
|
||||||
}
|
}
|
||||||
sqlx::mysql::MySqlConnectOptions::from_str(&fresh.url)
|
|
||||||
.unwrap()
|
|
||||||
.disable_statement_logging();
|
|
||||||
fresh
|
fresh
|
||||||
.pool_options
|
.pool_options
|
||||||
.connect_with(connect_options)
|
.connect_with(connect_options)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ async-trait = "0.1.51"
|
|||||||
db-core = {path = "../db-core"}
|
db-core = {path = "../db-core"}
|
||||||
futures = "0.3.15"
|
futures = "0.3.15"
|
||||||
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline" ] }
|
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline" ] }
|
||||||
|
urlencoding = "2.1.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "2"
|
actix-rt = "2"
|
||||||
|
|||||||
@@ -68,14 +68,13 @@ impl Connect for ConnectionOptions {
|
|||||||
async fn connect(self) -> DBResult<Self::Pool> {
|
async fn connect(self) -> DBResult<Self::Pool> {
|
||||||
let pool = match self {
|
let pool = match self {
|
||||||
Self::Fresh(fresh) => {
|
Self::Fresh(fresh) => {
|
||||||
let mut connect_options =
|
let mut connect_options = sqlx::postgres::PgConnectOptions::from_str(
|
||||||
sqlx::postgres::PgConnectOptions::from_str(&fresh.url).unwrap();
|
&urlencoding::encode(&fresh.url),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
if fresh.disable_logging {
|
if fresh.disable_logging {
|
||||||
connect_options.disable_statement_logging();
|
connect_options.disable_statement_logging();
|
||||||
}
|
}
|
||||||
sqlx::postgres::PgConnectOptions::from_str(&fresh.url)
|
|
||||||
.unwrap()
|
|
||||||
.disable_statement_logging();
|
|
||||||
fresh
|
fresh
|
||||||
.pool_options
|
.pool_options
|
||||||
.connect_with(connect_options)
|
.connect_with(connect_options)
|
||||||
|
|||||||
Reference in New Issue
Block a user