Merge pull request #10589 from annando/pleroma

Fix profile probing via Pleroma
This commit is contained in:
Hypolite Petovan 2021-08-09 10:55:19 -04:00 committed by GitHub
commit 8671439069
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 8 deletions

View File

@ -47,7 +47,7 @@ class Xrd extends BaseModule
} }
$uri = urldecode(Strings::escapeTags(trim($_GET['uri']))); $uri = urldecode(Strings::escapeTags(trim($_GET['uri'])));
if (($_SERVER['HTTP_ACCEPT'] ?? '') == 'application/jrd+json') { if (strpos($_SERVER['HTTP_ACCEPT'] ?? '', 'application/jrd+json') !== false) {
$mode = 'json'; $mode = 'json';
} else { } else {
$mode = 'xml'; $mode = 'xml';
@ -58,7 +58,7 @@ class Xrd extends BaseModule
} }
$uri = urldecode(Strings::escapeTags(trim($_GET['resource']))); $uri = urldecode(Strings::escapeTags(trim($_GET['resource'])));
if (($_SERVER['HTTP_ACCEPT'] ?? '') == 'application/xrd+xml') { if (strpos($_SERVER['HTTP_ACCEPT'] ?? '', 'application/xrd+xml') !== false) {
$mode = 'xml'; $mode = 'xml';
} else { } else {
$mode = 'json'; $mode = 'json';
@ -159,9 +159,6 @@ class Xrd extends BaseModule
{ {
$salmon_key = Salmon::salmonKey($owner['spubkey']); $salmon_key = Salmon::salmonKey($owner['spubkey']);
header('Access-Control-Allow-Origin: *');
header('Content-type: application/json; charset=utf-8');
$json = [ $json = [
'subject' => 'acct:' . $owner['addr'], 'subject' => 'acct:' . $owner['addr'],
'aliases' => [ 'aliases' => [
@ -235,8 +232,8 @@ class Xrd extends BaseModule
], ],
]; ];
echo json_encode($json); header('Access-Control-Allow-Origin: *');
exit(); System::jsonExit($json, 'application/jrd+json; charset=utf-8');
} }
private static function printXML($alias, $baseURL, $user, $owner, $avatar) private static function printXML($alias, $baseURL, $user, $owner, $avatar)

View File

@ -354,7 +354,7 @@ class Transmitter
$data['url'] = $owner['url']; $data['url'] = $owner['url'];
$data['manuallyApprovesFollowers'] = in_array($owner['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]); $data['manuallyApprovesFollowers'] = in_array($owner['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]);
$data['discoverable'] = $owner['net-publish']; $data['discoverable'] = (bool)$owner['net-publish'];
$data['publicKey'] = ['id' => $owner['url'] . '#main-key', $data['publicKey'] = ['id' => $owner['url'] . '#main-key',
'owner' => $owner['url'], 'owner' => $owner['url'],
'publicKeyPem' => $owner['pubkey']]; 'publicKeyPem' => $owner['pubkey']];