This commit is contained in:
Felix Ableitner 2024-11-12 12:12:48 +01:00
parent 3a5c621e17
commit 6a42c7dee7
2 changed files with 6 additions and 9 deletions

View file

@ -78,9 +78,6 @@ pub enum Error {
/// Attempted to fetch object but the response's id field doesn't match
#[error("Attempted to fetch object from {0} but the response's id field doesn't match")]
FetchWrongId(Url),
/// Object which has local domain cannot be fetched over HTTP
#[error("Object which has local domain cannot be fetched over HTTP")]
CannotDereferenceLocalObject,
/// Other generic errors
#[error("{0}")]
Other(String),

View file

@ -158,10 +158,6 @@ where
where
<Kind as Object>::Error: From<Error>,
{
if self.is_local(data) {
return Err(Error::CannotDereferenceLocalObject.into());
}
let res = Box::pin(fetch_object_http(&self.0, data)).await;
if let Err(Error::ObjectDeleted(url)) = res {
@ -174,8 +170,12 @@ where
let res = res?;
let redirect_url = &res.url;
if data.config.is_local_url(&redirect_url) {
return Err(Error::CannotDereferenceLocalObject.into());
// Prevent overwriting local object
if data.config.is_local_url(redirect_url) {
return self
.dereference_from_db(data)
.await?
.ok_or(Error::NotFound.into());
}
Box::pin(Kind::verify(&res.object, redirect_url, data)).await?;