mirror of
https://github.com/friendica/friendica
synced 2025-02-09 01:38:50 +00:00
Ward against invalid URLs in Model\Post\Media::isFederatedServer
- Add logger call for exception case - Address https://github.com/friendica/friendica/issues/14646#issuecomment-2614231345
This commit is contained in:
parent
5a00a2c441
commit
657c04a041
1 changed files with 14 additions and 8 deletions
|
@ -10,6 +10,7 @@ namespace Friendica\Model\Post;
|
|||
use Friendica\Content\PageInfo;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -255,16 +256,21 @@ class Media
|
|||
|
||||
private static function isFederatedServer(string $url): bool
|
||||
{
|
||||
$baseurl = Network::getBaseUrl(new Uri($url));
|
||||
if (empty($baseurl)) {
|
||||
try {
|
||||
$baseurl = Network::getBaseUrl(new Uri($url));
|
||||
if (empty($baseurl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Strings::compareLink($baseurl, ATProtocol::WEB)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return DBA::exists('gserver', ['nurl' => Strings::normaliseLink($baseurl), 'network' => Protocol::FEDERATED]);
|
||||
} catch(\Throwable $e) {
|
||||
DI::logger()->notice('Invalid URL provided', ['url' => $url, 'exception' => $e, 'callstack' => System::callstack(10)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Strings::compareLink($baseurl, ATProtocol::WEB)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return DBA::exists('gserver', ['nurl' => Strings::normaliseLink($baseurl), 'network' => Protocol::FEDERATED]);
|
||||
}
|
||||
|
||||
private static function addPreviewData(array $media): array
|
||||
|
|
Loading…
Add table
Reference in a new issue