Merge pull request #13492 from MrPetovan/bug/13359-mastodon-short-urls

Restore support for Mastodon profile short-form URLs
This commit is contained in:
Tobias Diekershoff 2023-10-04 07:47:21 +02:00 committed by GitHub
commit e45dbc9f6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -157,7 +157,10 @@ class APContact
$apcontact = [];
$webfinger = empty(parse_url($url, PHP_URL_SCHEME));
// Mastodon profile short-form URL https://domain.tld/@user doesn't return AP data when queried
// with HTTPSignature::fetchRaw, but returns the correct data when provided to WebFinger
// @see https://github.com/friendica/friendica/issues/13359
$webfinger = empty(parse_url($url, PHP_URL_SCHEME)) || strpos($url, '@') !== false;
if ($webfinger) {
$apcontact = self::fetchWebfingerData($url);
if (empty($apcontact['url'])) {
@ -197,7 +200,7 @@ class APContact
$curlResult = HTTPSignature::fetchRaw($url);
$failed = empty($curlResult) || empty($curlResult->getBody()) ||
(!$curlResult->isSuccess() && ($curlResult->getReturnCode() != 410));
if (!$failed) {
$data = json_decode($curlResult->getBody(), true);
$failed = empty($data) || !is_array($data);