Check for activity pub mime types

This commit is contained in:
Michael 2024-02-19 07:11:56 +00:00
parent cb294cf411
commit 892e0a5623
3 changed files with 24 additions and 5 deletions

View file

@ -443,9 +443,25 @@ class HTTPSignature
return [];
}
if (!self::isValidContentType($curlResult->getContentType())) {
Logger::notice('Unexpected content type', ['content-type' => $curlResult->getContentType(), 'url' => $request]);
return [];
}
return $content;
}
/**
* Check if the provided content type is a valid LD JSON mime type
*
* @param string $contentType
* @return boolean
*/
public static function isValidContentType(string $contentType): bool
{
return in_array(current(explode(';', $contentType)), ['application/activity+json', 'application/ld+json']);
}
/**
* Fetches raw data for a user
*