diff options
| author | Fuwn <[email protected]> | 2025-09-11 06:04:01 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-09-11 06:04:01 +0000 |
| commit | 51e79294d8fbfb1bd4be8584e2d32ff0712227aa (patch) | |
| tree | e77c766264366af78345c2e1da823e6610c852a6 /src/request/blocking.rs | |
| parent | fix(request): Handle malformed response header (diff) | |
| download | germ-51e79294d8fbfb1bd4be8584e2d32ff0712227aa.tar.xz germ-51e79294d8fbfb1bd4be8584e2d32ff0712227aa.zip | |
fix(request): Handle invalid URLs
Diffstat (limited to 'src/request/blocking.rs')
| -rw-r--r-- | src/request/blocking.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/request/blocking.rs b/src/request/blocking.rs index 2002ed8..984f886 100644 --- a/src/request/blocking.rs +++ b/src/request/blocking.rs @@ -44,13 +44,16 @@ pub fn request(url: &url::Url) -> anyhow::Result<Response> { .with_safe_defaults() .with_custom_certificate_verifier(std::sync::Arc::new(GermVerifier::new())) .with_no_client_auth(); + let domain = url + .domain() + .ok_or_else(|| anyhow::anyhow!("Invalid URL: missing domain"))?; let mut connection = rustls::ClientConnection::new( std::sync::Arc::new(config), - url.domain().unwrap_or("").try_into()?, + domain.try_into()?, )?; let mut stream = std::net::TcpStream::connect(format!( "{}:{}", - url.domain().unwrap_or(""), + domain, url.port().unwrap_or(1965) ))?; let mut tls = rustls::Stream::new(&mut connection, &mut stream); |