]> git.mxchange.org Git - friendica.git/commitdiff
Fix profile probing via Pleroma
authorMichael <heluecht@pirati.ca>
Mon, 9 Aug 2021 06:56:41 +0000 (06:56 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 9 Aug 2021 06:56:41 +0000 (06:56 +0000)
src/Module/Xrd.php
src/Protocol/ActivityPub/Transmitter.php

index d2813cc270ae0d39c479bc79e9cb4cd348651aea..aa7e04ebcd8097b7e721889d94c4089feb81fa00 100644 (file)
@@ -47,7 +47,7 @@ class Xrd extends BaseModule
                        }
 
                        $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';
                        } else {
                                $mode = 'xml';
@@ -58,7 +58,7 @@ class Xrd extends BaseModule
                        }
 
                        $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';
                        } else {
                                $mode = 'json';
@@ -159,9 +159,6 @@ class Xrd extends BaseModule
        {
                $salmon_key = Salmon::salmonKey($owner['spubkey']);
 
-               header('Access-Control-Allow-Origin: *');
-               header('Content-type: application/json; charset=utf-8');
-
                $json = [
                        'subject' => 'acct:' . $owner['addr'],
                        'aliases' => [
@@ -235,8 +232,8 @@ class Xrd extends BaseModule
                        ],
                ];
 
-               echo json_encode($json);
-               exit();
+               header('Access-Control-Allow-Origin: *');
+               System::jsonExit($json, 'application/jrd+json; charset=utf-8');
        }
 
        private static function printXML($alias, $baseURL, $user, $owner, $avatar)
index 6c78db302c4dedb975a54e2cb47756c2dfed7966..2ca40259d5095527a0bf6831e7ecc61b0762598f 100644 (file)
@@ -354,7 +354,7 @@ class Transmitter
 
                $data['url'] = $owner['url'];
                $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',
                        'owner' => $owner['url'],
                        'publicKeyPem' => $owner['pubkey']];