From 1361f0746774aa2c95c1ff0468d4418e0535b0f7 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Fri, 1 Jan 2021 20:09:52 -0800 Subject: [PATCH] Scheme-relative URLs are no longer allowed https://lists.orbitalfox.eu/archives/gemini/2020/003646.html --- src/main.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index f5054e3..cfe005b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -147,15 +147,10 @@ async fn parse_request(stream: &mut TlsStream) -> std::result::Result } buf = &mut request[len..]; } - let request = std::str::from_utf8(&request[..len - 2]).or(Err((59, "Invalid URL")))?; + let request = std::str::from_utf8(&request[..len - 2]).or(Err((59, "Non-UTF-8 request")))?; log::info!("Got request for {:?}", request); - // Handle scheme-relative URLs. - let url = if request.starts_with("//") { - Url::parse(&format!("gemini:{}", request)) - } else { - Url::parse(request) - }.or(Err((59, "Invalid URL")))?; + let url = Url::parse(request).or(Err((59, "Invalid URL")))?; // Validate the URL, host and port. if url.scheme() != "gemini" {