mirror of
https://github.com/LemmyNet/activitypub-federation-rust.git
synced 2025-03-13 18:52:39 +00:00
Remove trailing . from domain
This commit is contained in:
parent
9413bad37a
commit
531d4264cd
2 changed files with 11 additions and 2 deletions
|
@ -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(),
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue