From 99e30d561d38a555a09661d806ea443d17c3a486 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 26 Jan 2020 00:57:10 +0100 Subject: [PATCH] fix oauth2 login by fixing a Serde call oauth2 crashes in beta23 because we did not let Serde remove the quotes from a parsed JSON email-address. for autoconfig, we try to get a well-known URL containing the domain of the used address - with the quote that is https://autoconfig.gmail.com"/mail/config-v1.1.xml?... unfortunately, instead of just returning an error, (the url does not exist anyway) reqwest crashes on the attempt to get this URL. the Serde-thing is not obvious to me: while serde_json::Value.as_str() removes the quotes, serde_json::Value.to_string() does not. --- src/oauth2.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/oauth2.rs b/src/oauth2.rs index db00d8ec5..2e80e5fdb 100644 --- a/src/oauth2.rs +++ b/src/oauth2.rs @@ -311,9 +311,10 @@ impl Oauth2 { return None; } if let Ok(response) = parsed { - // serde_json::Value.as_str() removes the quotes of json-strings + // CAVE: serde_json::Value.as_str() removes the quotes of json-strings + // but serde_json::Value.to_string() does not! if let Some(addr) = response.get("email") { - Some(addr.to_string()) + addr.as_str().map(|s| s.to_string()) } else { warn!(context, "E-mail missing in userinfo."); None