mirror of
https://github.com/LemmyNet/activitypub-federation-rust.git
synced 2024-06-08 08:19:28 +00:00
content-type
This commit is contained in:
parent
26ac6e82dc
commit
b3978cf418
|
@ -57,11 +57,15 @@ pub async fn fetch_object_http<T: Clone, Kind: DeserializeOwned>(
|
||||||
static ALT_CONTENT_TYPE: HeaderValue = HeaderValue::from_static(
|
static ALT_CONTENT_TYPE: HeaderValue = HeaderValue::from_static(
|
||||||
r#"application/ld+json; profile="https://www.w3.org/ns/activitystreams""#,
|
r#"application/ld+json; profile="https://www.w3.org/ns/activitystreams""#,
|
||||||
);
|
);
|
||||||
|
static ALT_CONTENT_TYPE_MASTODON: HeaderValue = HeaderValue::from_static(
|
||||||
|
r#"application/activity+json; charset=utf-8"#,
|
||||||
|
);
|
||||||
let res = fetch_object_http_with_accept(url, data, &CONTENT_TYPE).await?;
|
let res = fetch_object_http_with_accept(url, data, &CONTENT_TYPE).await?;
|
||||||
|
|
||||||
// Ensure correct content-type to prevent vulnerabilities.
|
// Ensure correct content-type to prevent vulnerabilities.
|
||||||
if res.content_type.as_ref() != Some(&CONTENT_TYPE)
|
if res.content_type.as_ref() != Some(&CONTENT_TYPE)
|
||||||
&& res.content_type.as_ref() != Some(&ALT_CONTENT_TYPE)
|
&& res.content_type.as_ref() != Some(&ALT_CONTENT_TYPE)
|
||||||
|
&& res.content_type.as_ref() != Some(&ALT_CONTENT_TYPE_MASTODON)
|
||||||
{
|
{
|
||||||
return Err(Error::FetchInvalidContentType(res.url));
|
return Err(Error::FetchInvalidContentType(res.url));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue