Add percentage encoding and decoding to query handling
This commit is contained in:
parent
93d942b8a7
commit
6f71ab08f6
4 changed files with 11 additions and 1 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -371,6 +371,7 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
"urlencoding",
|
||||||
"which",
|
"which",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1451,6 +1452,12 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "urlencoding"
|
||||||
|
version = "2.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf8parse"
|
name = "utf8parse"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
|
|
@ -25,3 +25,4 @@ reqwest = { version = "0.11.24", optional = true, default-features = false, feat
|
||||||
tempfile = { version = "3.10.0", optional = true }
|
tempfile = { version = "3.10.0", optional = true }
|
||||||
which = { version = "6.0.0", optional = true }
|
which = { version = "6.0.0", optional = true }
|
||||||
nix = { version = "0.27.1", optional = true, default-features = false, features = ["signal"] }
|
nix = { version = "0.27.1", optional = true, default-features = false, features = ["signal"] }
|
||||||
|
urlencoding = { version = "2.1.3"}
|
|
@ -52,6 +52,7 @@ pub fn finger_fedi(client: &Client, handle: &str) -> Result<Resource, FediFinger
|
||||||
.split_once('@')
|
.split_once('@')
|
||||||
.ok_or(FediFingerError::MissingMiddleAt)?;
|
.ok_or(FediFingerError::MissingMiddleAt)?;
|
||||||
let account = format!("acct:{handle}");
|
let account = format!("acct:{handle}");
|
||||||
|
let account = urlencoding::encode(account.as_str());
|
||||||
|
|
||||||
let url =
|
let url =
|
||||||
Url::parse(format!("https://{domain}/.well-known/webfinger?resource={account}").as_str())
|
Url::parse(format!("https://{domain}/.well-known/webfinger?resource={account}").as_str())
|
||||||
|
|
|
@ -81,6 +81,7 @@ async fn run_webfinger_query(
|
||||||
info!("Received query with {uri}");
|
info!("Received query with {uri}");
|
||||||
let query = uri.query().ok_or(StatusCode::BAD_REQUEST)?;
|
let query = uri.query().ok_or(StatusCode::BAD_REQUEST)?;
|
||||||
debug!("Query string is {query}");
|
debug!("Query string is {query}");
|
||||||
|
let query = urlencoding::decode(query).map_err(|e| StatusCode::BAD_REQUEST)?;
|
||||||
let params = query
|
let params = query
|
||||||
.split('&')
|
.split('&')
|
||||||
.filter_map(|query_part| {
|
.filter_map(|query_part| {
|
||||||
|
|
Loading…
Reference in a new issue