Remove trailing . from domain

This commit is contained in:
Felix Ableitner 2025-01-13 15:28:39 +01:00
parent 9413bad37a
commit 531d4264cd
2 changed files with 11 additions and 2 deletions

View file

@ -46,7 +46,7 @@ async fn main() -> Result<(), Error> {
info!("Alpha user follows beta user via webfinger");
alpha
.local_user()
.follow("beta@localhost:8002", &alpha.to_request_data())
.follow("beta@localhost.:8002", &alpha.to_request_data())
.await?;
assert_eq!(
beta.local_user().followers(),

View file

@ -206,7 +206,16 @@ impl<T: Clone> FederationConfig<T> {
}
}
self.url_verifier.verify(url).await?;
// It is valid but uncommon for domains to end with `.` char. Drop this so it cant be used
// to bypass domain blocklist. Avoid cloning url in common case.
if domain.ends_with(".") {
let mut url = url.clone();
let domain = &domain[0..domain.len() - 1];
url.set_host(Some(domain))?;
self.url_verifier.verify(&url).await?;
} else {
self.url_verifier.verify(url).await?;
}
Ok(())
}