From db0ccc5b8c6305e63a92e577b62703331b01d363 Mon Sep 17 00:00:00 2001 From: Vika Date: Sun, 18 Aug 2024 01:14:11 +0300 Subject: Better match html content-type --- Cargo.lock | 1 + Cargo.toml | 1 + src/indieauth/mod.rs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index a2b49cd..3b4d347 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1640,6 +1640,7 @@ dependencies = [ "listenfd", "markdown", "microformats", + "mime", "newbase60", "prometheus", "rand 0.8.5", diff --git a/Cargo.toml b/Cargo.toml index ada6c98..958f605 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,6 +106,7 @@ tower = { version = "0.4.12", features = ["tracing"] } webauthn = { version = "0.5.0", package = "webauthn-rs", features = ["danger-allow-state-serialisation"], optional = true } base64 = "0.22.1" html5ever = "0.27.0" +mime = "0.3.17" [dependencies.tokio] version = "^1.29.1" features = ["full", "tracing"] # TODO determine if my app doesn't need some features diff --git a/src/indieauth/mod.rs b/src/indieauth/mod.rs index f7a9712..ba19b3b 100644 --- a/src/indieauth/mod.rs +++ b/src/indieauth/mod.rs @@ -149,7 +149,7 @@ async fn authorization_endpoint_get( let metadata_request = http.get(request.client_id.clone()) .header("Accept", "application/json, text/html"); match metadata_request.send().await.and_then(|res| res.error_for_status()) { - Ok(response) if response.headers().typed_get::() == Some(ContentType::html()) => { + Ok(response) if response.headers().typed_get::().to_owned().map(mime::Mime::from).map(|m| m.type_() == "text" && m.subtype() == "html").unwrap_or(false) => { let url = response.url().clone(); let text = response.text().await.unwrap(); tracing::debug!("Received {} bytes in response", text.len()); -- cgit 1.4.1