about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.toml1
-rw-r--r--src/indieauth/mod.rs2
3 files changed, 3 insertions, 1 deletions
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<A: AuthBackend, D: Storage + 'static>(
         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::<ContentType>() == Some(ContentType::html()) => {
+            Ok(response) if response.headers().typed_get::<ContentType>().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());