Don't use compacted data when parsing accounts

This commit is contained in:
Michael 2021-05-16 16:41:07 +00:00
parent a4a2f4616c
commit 6f2fcd2859
3 changed files with 55 additions and 42 deletions

View file

@ -24,6 +24,7 @@ namespace Friendica\Util;
use Friendica\Core\Cache\Duration;
use Friendica\Core\Logger;
use Exception;
use Friendica\Core\System;
use Friendica\DI;
/**
@ -67,6 +68,20 @@ class JsonLD
return $data;
}
public static function removeSecurityLink(array $json)
{
if (!is_array($json['@context'])) {
return $json;
}
if (($key = array_search('https://w3id.org/security/v1', $json['@context'])) !== false) {
unset($json['@context'][$key]);
$json['@context'] = array_values(array_filter($json['@context']));
}
return $json;
}
public static function fixContext(array $json)
{
// Preparation for adding possibly missing content to the context
@ -111,7 +126,7 @@ class JsonLD
*/
public static function normalize($json)
{
$json = self::fixContext($json);
$json = self::removeSecurityLink($json);
jsonld_set_document_loader('Friendica\Util\JsonLD::documentLoader');
@ -177,7 +192,7 @@ class JsonLD
}
catch (Exception $e) {
$compacted = false;
Logger::error('compacting error');
Logger::error('compacting error', ['callstack' => System::callstack(20)]);
// Sooner or later we should log some details as well - but currently this leads to memory issues
// Logger::log('compacting error:' . substr(print_r($e, true), 0, 10000), Logger::DEBUG);
}