mirror of
https://github.com/LemmyNet/activitypub-federation-rust.git
synced 2024-05-18 00:52:40 +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(
|
||||
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?;
|
||||
|
||||
// Ensure correct content-type to prevent vulnerabilities.
|
||||
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_MASTODON)
|
||||
{
|
||||
return Err(Error::FetchInvalidContentType(res.url));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue