Bluesky: Fix for the handling of invalid profiles #1553

Merged
tobias merged 1 commit from heluecht/friendica-addons:bluesky-fix into develop 2024-09-11 19:43:00 +02:00

View file

@ -1765,9 +1765,16 @@ function bluesky_get_did_by_profile(string $url): string
return ''; return '';
} }
$profile = $curlResult->getBodyString(); $profile = $curlResult->getBodyString();
if (empty($profile)) {
return '';
}
$doc = new DOMDocument(); $doc = new DOMDocument();
@$doc->loadHTML($profile); try {
@$doc->loadHTML($profile);
} catch (\Throwable $th) {
return '';
}
$xpath = new DOMXPath($doc); $xpath = new DOMXPath($doc);
$list = $xpath->query('//p[@id]'); $list = $xpath->query('//p[@id]');
foreach ($list as $node) { foreach ($list as $node) {