<?php
/**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
{
switch ($url) {
case 'https://w3id.org/security/v1':
- $url = DI::baseUrl() . '/static/security-v1.jsonld';
+ $url = DI::basePath() . '/static/security-v1.jsonld';
+ break;
+ case 'https://w3id.org/security/data-integrity/v1':
+ $url = DI::basePath() . '/static/security-data-integrity-v1.jsonld';
+ break;
+ case 'https://w3id.org/security/multikey/v1':
+ $url = DI::basePath() . '/static/security-multikey-v1.jsonld';
break;
case 'https://w3id.org/identity/v1':
- $url = DI::baseUrl() . '/static/identity-v1.jsonld';
+ $url = DI::basePath() . '/static/identity-v1.jsonld';
break;
case 'https://www.w3.org/ns/activitystreams':
- $url = DI::baseUrl() . '/static/activitystreams.jsonld';
+ $url = DI::basePath() . '/static/activitystreams.jsonld';
break;
case 'https://funkwhale.audio/ns':
- $url = DI::baseUrl() . '/static/funkwhale.audio.jsonld';
+ $url = DI::basePath() . '/static/funkwhale.audio.jsonld';
+ break;
+ case 'http://schema.org':
+ $url = DI::basePath() . '/static/schema.jsonld';
+ break;
+ case 'http://joinmastodon.org/ns':
+ $url = DI::basePath() . '/static/joinmastodon.jsonld';
break;
default:
switch (parse_url($url, PHP_URL_PATH)) {
case '/schemas/litepub-0.1.jsonld';
- $url = DI::baseUrl() . '/static/litepub-0.1.jsonld';
+ $url = DI::basePath() . '/static/litepub-0.1.jsonld';
break;
case '/apschema/v1.2':
case '/apschema/v1.9':
case '/apschema/v1.10':
- $url = DI::baseUrl() . '/static/apschema.jsonld';
+ $url = DI::basePath() . '/static/apschema.jsonld';
break;
default:
Logger::info('Got url', ['url' =>$url]);
* @return array Compacted JSON array
* @throws Exception
*/
- public static function compact($json, bool $logfailed = true)
+ public static function compact($json, bool $logfailed = true): array
{
jsonld_set_document_loader('Friendica\Util\JsonLD::documentLoader');
'mobilizon' => (object)['@id' => 'https://joinmobilizon.org/ns#', '@type' => '@id'],
'fedibird' => (object)['@id' => 'http://fedibird.com/ns#', '@type' => '@id'],
'misskey' => (object)['@id' => 'https://misskey-hub.net/ns#', '@type' => '@id'],
+ 'pixelfed' => (object)['@id' => 'http://pixelfed.org/ns#', '@type' => '@id'],
];
$orig_json = $json;
Logger::notice('compacting error', ['msg' => $e->getMessage(), 'previous' => $e->getPrevious(), 'line' => $e->getLine()]);
if ($logfailed && DI::config()->get('debug', 'ap_log_failure')) {
$tempfile = tempnam(System::getTempPath(), 'failed-jsonld');
- file_put_contents($tempfile, json_encode(['json' => $orig_json, 'callstack' => System::callstack(20), 'msg' => $e->getMessage(), 'previous' => $e->getPrevious()], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
+ file_put_contents($tempfile, json_encode(['json' => $orig_json, 'msg' => $e->getMessage(), 'previous' => $e->getPrevious()], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
Logger::notice('Failed message stored', ['file' => $tempfile]);
}
}
$json = json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true);
+ if ($json === false) {
+ Logger::notice('JSON encode->decode failed', ['orig_json' => $orig_json, 'compacted' => $compacted]);
+ $json = [];
+ }
+
return $json;
}